Skip to content

Commit

Permalink
优化 Flex 组件案例
Browse files Browse the repository at this point in the history
  • Loading branch information
toly1994328 committed Feb 21, 2022
1 parent 2cc5dad commit 1e858ac
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,40 @@ import 'package:flutter/material.dart';
// "【direction】 : 方向 【Axis】",
// }
class DirectionFlex extends StatelessWidget {
static TextStyle textStyle =
TextStyle(color: Colors.white, fontWeight: FontWeight.bold);

final redBox= Container(
color: Colors.red,
height: 30,
width: 40,
);

final blueBox= Container(
final blueBox = Container(
alignment: Alignment.center,
color: Colors.blue,
height: 20,
width: 30,
child: Text(
'1',
style: textStyle,
),
);

final redBox = Container(
alignment: Alignment.center,
color: Colors.red,
height: 30,
width: 40,
child: Text(
'2',
style: textStyle,
),
);

final greenBox= Container(
final greenBox = Container(
alignment: Alignment.center,
color: Colors.green,
height: 20,
width: 20,
child: Text(
'3',
style: textStyle,
),
);

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,40 @@ import 'package:flutter/material.dart';
// }
class MainAxisAlignmentFlex extends StatelessWidget {

final redBox= Container(
color: Colors.red,
height: 30,
width: 40,
);
static TextStyle textStyle =
TextStyle(color: Colors.white, fontWeight: FontWeight.bold);

final blueBox= Container(
final blueBox = Container(
alignment: Alignment.center,
color: Colors.blue,
height: 20,
width: 30,
child: Text(
'1',
style: textStyle,
),
);

final redBox = Container(
alignment: Alignment.center,
color: Colors.red,
height: 30,
width: 40,
child: Text(
'2',
style: textStyle,
),
);

final greenBox= Container(
final greenBox = Container(
alignment: Alignment.center,
color: Colors.green,
height: 20,
width: 20,
child: Text(
'3',
style: textStyle,
),
);

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,40 @@ import 'package:flutter/material.dart';
// }
class CrossAxisAlignmentFlex extends StatelessWidget {

final redBox= Container(
color: Colors.red,
height: 30,
width: 40,
);
static TextStyle textStyle =
TextStyle(color: Colors.white, fontWeight: FontWeight.bold);

final blueBox= Container(
final blueBox = Container(
alignment: Alignment.center,
color: Colors.blue,
height: 20,
width: 30,
child: Text(
'1',
style: textStyle,
),
);

final redBox = Container(
alignment: Alignment.center,
color: Colors.red,
height: 30,
width: 40,
child: Text(
'2',
style: textStyle,
),
);

final greenBox= Container(
final greenBox = Container(
alignment: Alignment.center,
color: Colors.green,
height: 20,
width: 20,
child: Text(
'3',
style: textStyle,
),
);

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,40 @@ import 'package:flutter/material.dart';
// }
class VerticalDirectionFlex extends StatelessWidget {

final redBox= Container(
color: Colors.red,
height: 30,
width: 40,
);
static TextStyle textStyle =
TextStyle(color: Colors.white, fontWeight: FontWeight.bold);

final blueBox= Container(
final blueBox = Container(
alignment: Alignment.center,
color: Colors.blue,
height: 20,
width: 30,
child: Text(
'1',
style: textStyle,
),
);

final redBox = Container(
alignment: Alignment.center,
color: Colors.red,
height: 30,
width: 40,
child: Text(
'2',
style: textStyle,
),
);

final greenBox= Container(
final greenBox = Container(
alignment: Alignment.center,
color: Colors.green,
height: 20,
width: 20,
child: Text(
'3',
style: textStyle,
),
);

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,40 @@ import 'package:flutter/material.dart';
// }
class TextDirectionFlex extends StatelessWidget {

final redBox= Container(
color: Colors.red,
height: 30,
width: 40,
);
static TextStyle textStyle =
TextStyle(color: Colors.white, fontWeight: FontWeight.bold);

final blueBox= Container(
final blueBox = Container(
alignment: Alignment.center,
color: Colors.blue,
height: 20,
width: 30,
child: Text(
'1',
style: textStyle,
),
);

final redBox = Container(
alignment: Alignment.center,
color: Colors.red,
height: 30,
width: 40,
child: Text(
'2',
style: textStyle,
),
);

final greenBox= Container(
final greenBox = Container(
alignment: Alignment.center,
color: Colors.green,
height: 20,
width: 20,
child: Text(
'3',
style: textStyle,
),
);

@override
Expand Down

0 comments on commit 1e858ac

Please sign in to comment.