0
我正在创建一个日历小部件。 我们在一周中的行标题中添加了一个DecoratedBox。 为什么使用Expanded时显示红色图层?为什么红色图层显示在Flutter上
展开时被排除,DecoratedBox没有展开......
class CalenderPage extends StatefulWidget {
@override
_CalenderPageState createState() => new _CalenderPageState();
}
class _CalenderPageState extends State<CalenderPage> {
DateTime now = new DateTime.now();
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Calender'),
),
body: new Center(
child: new Column(children: <Widget>[
new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: _createWeekOfDays()),
]),
),
);
}
List<Widget> _createWeekOfDays() {
List<Widget> _weekOfDays = new List<Widget>();
for (final weekOfDay in ['Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun',]) {
_weekOfDays.add(
new Expanded(
child: new DecoratedBox(
position: DecorationPosition.background,
decoration: new BoxDecoration(
border: new Border.all(
color: Theme.of(context).dividerColor, width: 1.0),
),
child: new Padding(
padding: new EdgeInsets.only(top: 8.0, bottom: 8.0),
child: new Text(
weekOfDay,
style: new TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
),
),
);
}
return _weekOfDays;
}
}