1 import ‘package:flutter/material.dart‘; 2 3 class LayoutDemo extends StatelessWidget{ 4 @override 5 Widget build(BuildContext context) { 6 // TODO: implement build 7 return new Scaffold( 8 appBar: new AppBar( 9 title: new Text(‘水平布局示例‘), 10 ), 11 body: new Row( 12 children: <Widget>[ 13 new Expanded(child: new Text(‘左侧文本‘,textAlign: TextAlign.center)), 14 new Expanded(child: new Text(‘中间文本‘,textAlign: TextAlign.center)), 15 new Expanded(child: new FittedBox(fit: BoxFit.contain,child: const FlutterLogo())) 16 ], 17 ), 18 ); 19 } 20 } 21 22 void main(){ 23 runApp( 24 new MaterialApp( 25 title: ‘水平对齐‘, 26 home: new LayoutDemo(), 27 ), 28 ); 29 }