gpt4 book ai didi

flutter - Flutter-无限容器

转载 作者:行者123 更新时间:2023-12-03 03:56:13 24 4
gpt4 key购买 nike

我试图在flutter中创建一个多项选择测验。我希望4个答案选项始终位于页面底部,而不考虑问题的大小。问题是,如果问题足够长,可以“推送”底部的4answer选项很好,但是如果问题很小(如您在屏幕截图中所见),则4个答案选项是“向上”,从问题开始。因此,我认为使用无穷大容器是个好主意,但没有用。您有什么想法要“锁定”页面底部的4个答案选项吗?谢谢。
short text image

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class questionpage extends StatefulWidget {
@override
_questionpageState createState() => _questionpageState();
}

class _questionpageState extends State<questionpage> {

int qnum = 0;
int score = 0;
int seconds = 10;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.indigoAccent[700],
title: SafeArea(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Text(
'$qnum/10 ',
style: TextStyle(
fontSize: 28,
),
),
),
Container(
child: Text(
'$seconds',
style: TextStyle(
fontSize: 28,
),
),
),
Container(
child: Text(
'Score: $score',
style: TextStyle(
fontSize: 28,
),
),
),
],
),
),
),
body: Column(children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(0, 30, 0, 0),
child: Text(
'Question $qnum:',
style: new TextStyle(
color: Colors.black,
fontSize: 32.0,
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
decorationThickness: 3.0,
),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Flexible(
// margin: EdgeInsets.fromLTRB(0, 5, 0, 0),
child: Container(
margin: EdgeInsets.fromLTRB(0, 5, 0, 0),
//padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new Text(
'This is a short question:',
style: new TextStyle(
color: Colors.black,
fontSize: 26.0,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
],
),
),
),
],
),
Container(
height: 80.0,
margin: EdgeInsets.fromLTRB(10, 20, 10, 5),
child: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: RaisedButton(
onPressed: () {},
child: Text(
'Να αγωνίζονται σε ποδοσφαιρικές ομάδες όποιας χώρας ήθελαν',
style: new TextStyle(
color: Colors.black,
fontSize: 21.0,
fontWeight: FontWeight.bold
),
textAlign: TextAlign.center,
),
color: Colors.amberAccent,
),
),
),
Container(
height: 80.0,
margin: EdgeInsets.fromLTRB(10, 5, 10, 5),
child: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: RaisedButton(
onPressed: () {},
child: Text(
'Να επιλέξουν την υπηκοότητα που προτιμούσαν',
style: new TextStyle(
color: Colors.black,
fontSize: 21.0,
fontWeight: FontWeight.bold
),
textAlign: TextAlign.center,
),
color: Colors.amberAccent,
),
),
),
Container(
height: 80.0,
margin: EdgeInsets.fromLTRB(10, 5, 10, 5),
child: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: RaisedButton(
onPressed: () {},
child: Text(
'Να διακινούνται χωρίς έλεγχο διαβατηρίων στα σύνορα',
style: new TextStyle(
color: Colors.black,
fontSize: 21.0,
fontWeight: FontWeight.bold
),
textAlign: TextAlign.center,
),
color: Colors.amberAccent,
),
),
),
Container(
height: 80.0,
margin: EdgeInsets.fromLTRB(10, 5, 10, 5),
child: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: RaisedButton(
onPressed: () {},
child: Text(
'Να επιλέγουν τη χώρα στην οποία θα πληρώνουν φόρο εισοδήματος',
style: new TextStyle(
color: Colors.black,
fontSize: 21.0,
fontWeight: FontWeight.bold
),
textAlign: TextAlign.center,
),
color: Colors.amberAccent,
),
),
),
],),
);
}
}

最佳答案

展开的小部件可以解决您的问题。

在第二个“行”窗口小部件之后添加下一行。

      Expanded(child: Container()),

下面的代码也清楚了更多的想法。
    Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Flexible(
// margin: EdgeInsets.fromLTRB(0, 5, 0, 0),
child: Container(
margin: EdgeInsets.fromLTRB(0, 5, 0, 0),
//padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new Text(
'This is a short question:',
style: new TextStyle(
color: Colors.black,
fontSize: 26.0,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
],
),
),
),
],
),
Expanded(child: Container()), // added line
Container(
height: 80.0,
margin: EdgeInsets.fromLTRB(10, 20, 10, 5),
child: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: RaisedButton(
onPressed: () {},
child: Text(
'Να αγωνίζονται σε ποδοσφαιρικές ομάδες όποιας χώρας ήθελαν',
style: new TextStyle(
color: Colors.black,
fontSize: 21.0,
fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),

关于flutter - Flutter-无限容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61139577/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com