forked from lxm_flutter/FlutterUnit
代码格式优化完毕
This commit is contained in:
@@ -12,41 +12,33 @@ import 'package:flutter/material.dart';
|
||||
// "【textDirection】 : 水平方向顺序 【TextDirection】",
|
||||
// }
|
||||
class TextDirectionFlex extends StatelessWidget {
|
||||
TextDirectionFlex({Key? key}) : super(key: key);
|
||||
|
||||
static TextStyle textStyle =
|
||||
TextStyle(color: Colors.white, fontWeight: FontWeight.bold);
|
||||
const TextStyle(color: Colors.white, fontWeight: FontWeight.bold);
|
||||
|
||||
final blueBox = Container(
|
||||
final Widget blueBox = Container(
|
||||
alignment: Alignment.center,
|
||||
color: Colors.blue,
|
||||
height: 20,
|
||||
width: 30,
|
||||
child: Text(
|
||||
'1',
|
||||
style: textStyle,
|
||||
),
|
||||
child: Text('1', style: textStyle),
|
||||
);
|
||||
|
||||
final redBox = Container(
|
||||
final Widget redBox = Container(
|
||||
alignment: Alignment.center,
|
||||
color: Colors.red,
|
||||
height: 30,
|
||||
width: 40,
|
||||
child: Text(
|
||||
'2',
|
||||
style: textStyle,
|
||||
),
|
||||
child: Text('2', style: textStyle),
|
||||
);
|
||||
|
||||
final greenBox = Container(
|
||||
final Widget greenBox = Container(
|
||||
alignment: Alignment.center,
|
||||
color: Colors.green,
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: Text(
|
||||
'3',
|
||||
style: textStyle,
|
||||
),
|
||||
child: Text('3', style: textStyle),
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -56,21 +48,19 @@ class TextDirectionFlex extends StatelessWidget {
|
||||
children: TextDirection.values
|
||||
.map((mode) => Column(children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.all(5),
|
||||
width: 160,
|
||||
height: 80,
|
||||
color: Colors.grey.withAlpha(33),
|
||||
child: _buildItem(mode)),
|
||||
margin: const EdgeInsets.all(5),
|
||||
width: 160,
|
||||
height: 80,
|
||||
color: Colors.grey.withAlpha(33),
|
||||
child: _buildItem(mode)),
|
||||
Text(mode.toString().split('.')[1])
|
||||
]))
|
||||
.toList());
|
||||
}
|
||||
|
||||
_buildItem(mode) => Flex(
|
||||
direction: Axis.horizontal,
|
||||
textDirection: mode,
|
||||
children: <Widget>[
|
||||
blueBox, redBox, greenBox
|
||||
],
|
||||
);
|
||||
Widget _buildItem(mode) => Flex(
|
||||
direction: Axis.horizontal,
|
||||
textDirection: mode,
|
||||
children: <Widget>[blueBox, redBox, greenBox],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user