我建议您仅开始构建布局,
Row而
Column不要感到困惑。我经常按如下方式构建布局。
- 仅使用
Row
和布局对象(例如,文本,图像)Column
。并在和中设置mainAxisAlignment
和crossAxisAlignment
属性。Row``Column
- 设置样式
Padding
或者Align
,Expanded
等你也可以使用Container
。 - 另外装饰。
参考:
布局基本:
https://flutter.dev/docs/development/ui/layout
构建布局时的提示:
https://medium.com/@liewjuntung/tips-on-using-android-studio-to-develop-
flutter-apps-9e42c047b7f4
希望对您有帮助。
示例代码:
Widget buildCard() { return Container( margin: EdgeInsets.all(10.0), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color.fromARGB(100, 0, 0, 0), blurRadius: 5, ), ], ), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Image.asset( 'assets/card.png', height: 62, width: 62, fit: BoxFit.cover, ), Padding( padding: const EdgeInsets.only(top: 12.0, left: 12.0), child: Text( "Hello world", style: TextStyle( fontWeight: FontWeight.w500, letterSpacing: 0.8, ), ), ) ], ), ); }


