【发布时间】:2022-09-30 03:39:29
【问题描述】:
这是我的第一个问题,我是 Flutter 的新手。我搜索了很多,但我没有找到任何合适的答案。
Flutter:我需要灵活设置盒子高度以适应任何尺寸的屏幕。我还需要将最后一个盒子放在屏幕右侧以适应任何屏幕。我还在屏幕图像中提到了我的问题。请帮忙。我在这里添加我的代码。
我的代码的输出和要求
void main() {
runApp(const Challange2());
}
class Challange2 extends StatelessWidget {
const Challange2({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.blueGrey,
body: SafeArea(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
height: 850.0,
width: 100.0,
color: Colors.amberAccent,
child: Text(
\'This box height should be flexible according to screen size\',
style: TextStyle(color: Colors.black, fontSize: 25),
),
),
const SizedBox(
width: 65,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: 100.0,
width: 100.0,
color: Colors.deepPurpleAccent,
child: Text(
\'Text2\',
style: TextStyle(color: Colors.white, fontSize: 25),
),
),
Container(
height: 100.0,
width: 100.0,
color: Colors.deepOrangeAccent,
//Flexible(
child: Text(
\'Text3\',
style: TextStyle(color: Colors.white, fontSize: 25),
),
),
//),
],
),
const SizedBox(
width: 65,
),
Container(
height: 850.0,
width: 100.0,
color: Colors.blue,
child: Text(
\'This box need to be right alignment and height should be flexible according to screen size\',
style: TextStyle(color: Colors.black, fontSize: 25),
),
// child: const Align(
// alignment: Alignment.topCenter,
),
],
),
),
),
//),
//return Container();
);
}
}
标签: flutter dart flutter-layout