Skip to content

Commit b3986d9

Browse files
committed
TextButton.styleFrom replace ButtonStyle
1 parent ba0a1c8 commit b3986d9

File tree

5 files changed

+40
-41
lines changed

5 files changed

+40
-41
lines changed

lib/page/error_page.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ class ErrorPageState extends State<ErrorPage> {
8080
mainAxisAlignment: MainAxisAlignment.center,
8181
children: <Widget>[
8282
new TextButton(
83-
style: ButtonStyle(
84-
backgroundColor: ButtonStyleButton.allOrNull<Color>(
85-
GSYColors.white.withAlpha(100)),
83+
style: TextButton.styleFrom(
84+
backgroundColor: GSYColors.white.withAlpha(100),
8685
),
8786
onPressed: () {
8887
String content = widget.errorMessage;
@@ -116,10 +115,8 @@ class ErrorPageState extends State<ErrorPage> {
116115
width: 40,
117116
),
118117
new TextButton(
119-
style: ButtonStyle(
120-
backgroundColor: ButtonStyleButton.allOrNull<Color>(
121-
Colors.white.withAlpha(100)),
122-
),
118+
style: TextButton.styleFrom(
119+
backgroundColor: Colors.white.withAlpha(100)),
123120
onPressed: () {
124121
Navigator.of(context).pop();
125122
},

lib/page/issue/widget/issue_header_item.dart

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class IssueHeaderItem extends StatelessWidget {
2222
IssueHeaderItem(this.issueHeaderViewModel, {this.onPressed});
2323

2424
_renderBottomContainer() {
25-
Color issueStateColor = issueHeaderViewModel.state == "open" ? Colors.green : Colors.red;
25+
Color issueStateColor =
26+
issueHeaderViewModel.state == "open" ? Colors.green : Colors.red;
2627

2728
///底部Issue状态
2829
Widget bottomContainer = new Row(
@@ -42,7 +43,8 @@ class IssueHeaderItem extends StatelessWidget {
4243
new Padding(padding: new EdgeInsets.all(2.0)),
4344

4445
///issue issue编码
45-
new Text(issueHeaderViewModel.issueTag, style: GSYConstant.smallTextWhite),
46+
new Text(issueHeaderViewModel.issueTag,
47+
style: GSYConstant.smallTextWhite),
4648
new Padding(padding: new EdgeInsets.all(2.0)),
4749

4850
///issue 评论数
@@ -61,7 +63,8 @@ class IssueHeaderItem extends StatelessWidget {
6163

6264
///关闭操作人
6365
_renderCloseByText() {
64-
return (issueHeaderViewModel.closedBy == null || issueHeaderViewModel.closedBy!.trim().length == 0)
66+
return (issueHeaderViewModel.closedBy == null ||
67+
issueHeaderViewModel.closedBy!.trim().length == 0)
6568
? new Container()
6669
: new Container(
6770
child: new Text(
@@ -77,10 +80,7 @@ class IssueHeaderItem extends StatelessWidget {
7780
return new GSYCardItem(
7881
color: Theme.of(context).primaryColor,
7982
child: new TextButton(
80-
style: ButtonStyle(
81-
padding: ButtonStyleButton.allOrNull<EdgeInsetsGeometry>(
82-
EdgeInsets.all(0.0)),
83-
),
83+
style: TextButton.styleFrom(padding: EdgeInsets.all(0.0)),
8484
onPressed: onPressed,
8585
child: new Padding(
8686
padding: new EdgeInsets.all(10.0),
@@ -91,12 +91,15 @@ class IssueHeaderItem extends StatelessWidget {
9191
children: <Widget>[
9292
///头像
9393
new GSYUserIconWidget(
94-
padding: const EdgeInsets.only(top: 0.0, right: 10.0, left: 0.0),
94+
padding: const EdgeInsets.only(
95+
top: 0.0, right: 10.0, left: 0.0),
9596
width: 50.0,
9697
height: 50.0,
97-
image: issueHeaderViewModel.actionUserPic ?? GSYICons.DEFAULT_REMOTE_PIC,
98+
image: issueHeaderViewModel.actionUserPic ??
99+
GSYICons.DEFAULT_REMOTE_PIC,
98100
onPressed: () {
99-
NavigatorUtils.goPerson(context, issueHeaderViewModel.actionUser);
101+
NavigatorUtils.goPerson(
102+
context, issueHeaderViewModel.actionUser);
100103
}),
101104
new Expanded(
102105
child: Column(
@@ -105,7 +108,10 @@ class IssueHeaderItem extends StatelessWidget {
105108
new Row(
106109
children: <Widget>[
107110
///名称
108-
new Expanded(child: new Text(issueHeaderViewModel.actionUser!, style: GSYConstant.normalTextWhite)),
111+
new Expanded(
112+
child: new Text(
113+
issueHeaderViewModel.actionUser!,
114+
style: GSYConstant.normalTextWhite)),
109115

110116
///时间
111117
new Text(
@@ -129,7 +135,8 @@ class IssueHeaderItem extends StatelessWidget {
129135
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
130136
alignment: Alignment.topLeft),
131137
new Padding(
132-
padding: new EdgeInsets.only(left: 0.0, top: 2.0, right: 0.0, bottom: 0.0),
138+
padding: new EdgeInsets.only(
139+
left: 0.0, top: 2.0, right: 0.0, bottom: 0.0),
133140
),
134141
],
135142
),
@@ -138,7 +145,9 @@ class IssueHeaderItem extends StatelessWidget {
138145
),
139146

140147
///评论内容
141-
GSYMarkdownWidget(markdownData: issueHeaderViewModel.issueDesHtml, style: GSYMarkdownWidget.DARK_THEME),
148+
GSYMarkdownWidget(
149+
markdownData: issueHeaderViewModel.issueDesHtml,
150+
style: GSYMarkdownWidget.DARK_THEME),
142151

143152
///close 用户
144153
_renderCloseByText()
@@ -173,7 +182,11 @@ class IssueHeaderViewModel {
173182
closedBy = issueMap.closeBy != null ? issueMap.closeBy!.login : "";
174183
locked = issueMap.locked;
175184
issueComment = issueMap.title;
176-
issueDesHtml = issueMap.bodyHtml != null ? issueMap.bodyHtml : (issueMap.body != null) ? issueMap.body : "";
185+
issueDesHtml = issueMap.bodyHtml != null
186+
? issueMap.bodyHtml
187+
: (issueMap.body != null)
188+
? issueMap.body
189+
: "";
177190
commentCount = issueMap.commentNum.toString() + "";
178191
state = issueMap.state;
179192
issueDes = issueMap.body != null ? ": \n" + issueMap.body! : '';

lib/page/push/widget/push_header.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ class PushHeader extends StatelessWidget {
3434
return new GSYCardItem(
3535
color: Theme.of(context).primaryColor,
3636
child: new TextButton(
37-
style: ButtonStyle(
38-
padding: ButtonStyleButton.allOrNull<EdgeInsetsGeometry>(
39-
new EdgeInsets.all(0.0)),
40-
),
37+
style: TextButton.styleFrom(padding: new EdgeInsets.all(0.0)),
4138
onPressed: () {},
4239
child: new Padding(
4340
padding: new EdgeInsets.all(10.0),

lib/test/demo_bloc_page.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,12 @@ class _LoginPageState extends State<LoginPage> with LoginBLoC {
7171
height: 40,
7272
width: constraints.maxWidth,
7373
child: new TextButton(
74-
style: ButtonStyle(
75-
textStyle:
76-
ButtonStyleButton.allOrNull<TextStyle>(
77-
TextStyle(
74+
style: TextButton.styleFrom(
75+
textStyle: TextStyle(
7876
color: Colors.white,
79-
)),
77+
),
8078
backgroundColor:
81-
ButtonStyleButton.allOrNull<Color>(
82-
Theme.of(context).primaryColor)),
79+
Theme.of(context).primaryColor),
8380
child: new Text("登陆",
8481
style: new TextStyle(fontSize: 14),
8582
textAlign: TextAlign.center,

lib/widget/gsy_flex_button.dart

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,10 @@ class GSYFlexButton extends StatelessWidget {
3232
@override
3333
Widget build(BuildContext context) {
3434
return new ElevatedButton(
35-
style: ButtonStyle(
36-
backgroundColor: ButtonStyleButton.allOrNull<Color>(
37-
color,
38-
),
39-
padding: ButtonStyleButton.allOrNull<EdgeInsetsGeometry>(
40-
new EdgeInsets.only(
41-
left: 20.0, top: 10.0, right: 20.0, bottom: 10.0),
42-
),
43-
),
35+
style: TextButton.styleFrom(
36+
backgroundColor: color,
37+
padding: new EdgeInsets.only(
38+
left: 20.0, top: 10.0, right: 20.0, bottom: 10.0)),
4439
child: new Flex(
4540
mainAxisAlignment: mainAxisAlignment,
4641
direction: Axis.horizontal,

0 commit comments

Comments
 (0)