Skip to content

Commit 06058fc

Browse files
committed
优化样式与组件溢出问题
1 parent 0b05954 commit 06058fc

File tree

3 files changed

+84
-71
lines changed

3 files changed

+84
-71
lines changed

lib/components/exampleComp.dart

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@ class Index extends StatelessWidget {
1111

1212
@override
1313
Widget build(BuildContext context) {
14+
Size size = MediaQuery.of(context).size;
15+
double _dp = 1.4;
1416
return Store.connect(
1517
builder: (context, child, MainStateModel model) {
16-
return Container(
17-
height: 420.0,
18-
margin: EdgeInsets.fromLTRB(50, 40, 50, 40),
19-
decoration: BoxDecoration(
20-
border: Border.all(color: Color(AppTheme.mainColor), width: 1.0),
18+
return Center(
19+
child: Container(
20+
width: size.width / _dp,
21+
height: size.height / _dp,
22+
margin: EdgeInsets.all(30 / _dp),
23+
decoration: BoxDecoration(
24+
border: Border.all(color: Color(AppTheme.mainColor), width: 1.0),
25+
),
26+
child: this.child,
2127
),
22-
child: this.child,
2328
);
2429
},
2530
);

lib/page/home.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:efox_flutter/lang/application.dart';
33
import 'package:efox_flutter/lang/app_translations.dart';
4-
import 'package:flutter_screenutil/flutter_screenutil.dart';
4+
import 'package:flutter_screenutil/flutter_screenutil.dart' show ScreenUtil;
55
import 'package:efox_flutter/store/store.dart' show Store;
66

77
import 'package:efox_flutter/components/header.dart' as Header;

lib/widget/regular/row/demo.dart

Lines changed: 72 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)