@@ -29,72 +29,80 @@ class _IndexState extends State<Index> {
2929 @override
3030 Widget build (BuildContext context) {
3131 return Scaffold (
32- appBar: AppBar (
33- title: Text ('Row Demo' ),
34- ),
35- body: ListView (
36- children: < Widget > [
37- SizedBox (
38- // height: 100.0,
39- child: Text ('修改mainAxisAligment的值' ),
40- ),
41- Row (
42- children: List .generate (3 , (index) {
43- return FlatButton (
44- child: Text ('${mainValue1 [index ]}' ),
45- onPressed: (){
46- setState (() {
47- mainAxisAlignmentIndex = index;
48- });
49- },
32+ appBar: AppBar (
33+ title: Text ('Row Demo' ),
34+ ),
35+ body: ListView (
36+ children: < Widget > [
37+ SizedBox (
38+ // height: 100.0,
39+ child: Text ('修改mainAxisAligment的值' ),
40+ ),
41+ Row (
42+ children: List .generate (3 , (index) {
43+ return Expanded (
44+ child: FlatButton (
45+ child: Text ('${mainValue1 [index ]}' ),
46+ onPressed: () {
47+ setState (() {
48+ mainAxisAlignmentIndex = index;
49+ });
50+ },
51+ ),
5052 );
51- })
52- ),
53- Row (
54- children: List .generate (3 , (index) {
55- return FlatButton (
56- child: Text ('${mainValue2 [index ]}' ),
57- onPressed: (){
58- setState (() {
59- mainAxisAlignmentIndex = index + 3 ;
60- });
61- },
53+ })),
54+ Row (
55+ children: List .generate (3 , (index) {
56+ return Expanded (
57+ child: FlatButton (
58+ child: Text ('${mainValue2 [index ]}' ),
59+ onPressed: () {
60+ setState (() {
61+ mainAxisAlignmentIndex = index + 3 ;
62+ });
63+ },
64+ ),
6265 );
63- })
64- ),
65- SizedBox (
66- child: Text ('修改crossAxisAlignment的值' )
67- ),
68- Row (
69- children: List .generate (3 , (index) {
70- return FlatButton (
71- child: Text ('${crossValue1 [index ]}' ),
72- onPressed: (){
73- setState (() {
74- crossAxisAlignmentIndex = index;
75- });
76- },
66+ })),
67+ SizedBox (child: Text ('修改crossAxisAlignment的值' )),
68+ Row (
69+ children: List .generate (3 , (index) {
70+ return Expanded (
71+ child: FlatButton (
72+ child: Text ('${crossValue1 [index ]}' ),
73+ onPressed: () {
74+ setState (() {
75+ crossAxisAlignmentIndex = index;
76+ });
77+ },
78+ ),
7779 );
78- })
79- ),
80- Row (
81- mainAxisAlignment: mainAxisAlignment[mainAxisAlignmentIndex],
82- crossAxisAlignment: crossAxisAlignment[crossAxisAlignmentIndex],
83- mainAxisSize: MainAxisSize .max,
84- children: < Widget > [
85- Image .network (
86- 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSP6WANi6lLUbgVdbwxt0ADhbwPrpEa3IGMAOzgfBFMukYsmSKB' ,
87- width: 80.0 , fit: BoxFit .cover,),
88- Image .network (
89- 'http://pic.ffpic.com/files/2015/0321/0321ktbdbsjbzdq1.jpg' ,
90- width: 80.0 , height: 180.0 , fit: BoxFit .cover,),
91- Image .network (
92- 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzaRpH9hl6NsFdTw_c3CLTc9CCXcvH-Vo4HK8fb6asgQbaTMHJ' ,
93- width: 80.0 , height: 100.0 , fit: BoxFit .cover,)
94- ],
95- )
96- ],
97- )
98- );
80+ })),
81+ Row (
82+ mainAxisAlignment: mainAxisAlignment[mainAxisAlignmentIndex],
83+ crossAxisAlignment: crossAxisAlignment[crossAxisAlignmentIndex],
84+ mainAxisSize: MainAxisSize .max,
85+ children: < Widget > [
86+ Image .network (
87+ 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSP6WANi6lLUbgVdbwxt0ADhbwPrpEa3IGMAOzgfBFMukYsmSKB' ,
88+ width: 80.0 ,
89+ fit: BoxFit .cover,
90+ ),
91+ Image .network (
92+ 'http://pic.ffpic.com/files/2015/0321/0321ktbdbsjbzdq1.jpg' ,
93+ width: 80.0 ,
94+ height: 180.0 ,
95+ fit: BoxFit .cover,
96+ ),
97+ Image .network (
98+ 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzaRpH9hl6NsFdTw_c3CLTc9CCXcvH-Vo4HK8fb6asgQbaTMHJ' ,
99+ width: 80.0 ,
100+ height: 100.0 ,
101+ fit: BoxFit .cover,
102+ )
103+ ],
104+ )
105+ ],
106+ ));
99107 }
100108}
0 commit comments