flutter - FLUTTER 如何在附加的法师中创建设计
问题描述
有了颤振,我想创建以下设计。居中的顶部标题并不那么重要。
如何创建如下图所示的设计。
使用堆栈会很好。
解决方案
试试这个:
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('SOME CENTERED TITLE'),
SizedBox(
height: 10,
),
Container(
height: 300,
padding: EdgeInsets.only(left: 5),
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 4,
),
),
child: Column(
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: Container(
height: 60,
width: 120,
color: Colors.black,
),
),
SizedBox(
height: 20,
),
Text('SOME CENTERED TEXT'),
SizedBox(
height: 20,
),
Text('SOME ANOTHER TEXT'),
],
),
),
SizedBox(
height: 50,
),
Row(
children: <Widget>[
Expanded(
child: Container(
height: 100,
color: Colors.red,
child: Center(
child: Text('Text'),
),
),
),
SizedBox(width: 50),
Expanded(
child: Container(
height: 100,
color: Colors.red,
child: Center(
child: Text('Text'),
),
),
)
],
),
],
),
),
),
);
}
}
输出:
推荐阅读
- mediawiki - 如何添加多种 Google 字体
- sbt - 在 0.13.x 中默认在子项目的上下文中执行“运行”
- javascript - 如何找出 JavaScript 错误对象中的类型 3 错误?
- r - 从 processMapR 中的活动中检索信息
- python - ImportError:没有名为“板”的模块(AdaFruit)
- c# - 如何初始化和使用数组
- java - 以方法引用为参数的单元测试方法
- django - 如何从 Angular 7 访问 Django 方法
- python - 处理大图像时的 Python 内存管理
- selenium - Selenium Actions click() 方法不起作用