Skip to content

Commit fdb82b9

Browse files
committed
prefer_const_constructors
1 parent 725da7d commit fdb82b9

File tree

15 files changed

+32
-38
lines changed

15 files changed

+32
-38
lines changed

lib/app.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
108108
routes: {
109109
WelcomePage.sName: (context) {
110110
DebugLabel.showDebugLabel(context);
111-
return WelcomePage();
111+
return const WelcomePage();
112112
},
113113
HomePage.sName: (context) {
114-
return NavigatorUtils.pageContainer(HomePage(), context);
114+
return NavigatorUtils.pageContainer(const HomePage(), context);
115115
},
116116
LoginPage.sName: (context) {
117-
return NavigatorUtils.pageContainer(LoginPage(), context);
117+
return NavigatorUtils.pageContainer(const LoginPage(), context);
118118
},
119119

120120
///使用 ModalRoute.of(context).settings.arguments; 获取参数
121121
PhotoViewPage.sName: (context) {
122-
return PhotoViewPage();
122+
return const PhotoViewPage();
123123
},
124124
});
125125

lib/common/scoped_model/scoped_model.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,8 @@ class _InheritedModel<T extends Model> extends InheritedWidget {
193193
final T? model;
194194
final int? version;
195195

196-
_InheritedModel({super.key, Widget? child, T? model})
197-
: model = model,
198-
version = model?._version,
196+
_InheritedModel({super.key, Widget? child, this.model})
197+
: version = model?._version,
199198
super(child: child!);
200199

201200
@override

lib/common/utils/event_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class EventUtils {
117117
break;
118118
}
119119

120-
return (actionStr: actionStr, des: des != null ? des : "");
120+
return (actionStr: actionStr, des: des ?? "");
121121
}
122122

123123
///跳转

lib/common/utils/navigator_utils.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class NavigatorUtils {
8181

8282
///请求数据调试页面
8383
static goDebugDataPage(BuildContext context) {
84-
return NavigatorRouter(context, DebugDataPage());
84+
return NavigatorRouter(context, const DebugDataPage());
8585
}
8686

8787
///仓库详情
@@ -187,12 +187,12 @@ class NavigatorUtils {
187187

188188
///仓库详情通知
189189
static Future goNotifyPage(BuildContext context) {
190-
return NavigatorRouter(context, NotifyPage());
190+
return NavigatorRouter(context, const NotifyPage());
191191
}
192192

193193
///用户趋势
194194
static Future goTrendUserPage(BuildContext context) {
195-
return NavigatorRouter(context, TrendUserPage());
195+
return NavigatorRouter(context, const TrendUserPage());
196196
}
197197

198198
///搜索
@@ -289,7 +289,7 @@ class NavigatorUtils {
289289

290290
///用户配置
291291
static gotoUserProfileInfo(BuildContext context) {
292-
NavigatorRouter(context, UserProfileInfo());
292+
NavigatorRouter(context, const UserProfileInfo());
293293
}
294294

295295
///公共打开方式

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void main() {
1919
};
2020
runApp(ConfigWrapper(
2121
config: EnvConfig.fromJson(config),
22-
child: FlutterReduxApp(),
22+
child: const FlutterReduxApp(),
2323
));
2424
///屏幕刷新率和显示率不一致时的优化,必须挪动到 runApp 之后
2525
GestureBinding.instance.resamplingEnabled = true;

lib/main_prod.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void main() {
2020
};
2121
runApp(ConfigWrapper(
2222
config: EnvConfig.fromJson(config),
23-
child: FlutterReduxApp(),
23+
child: const FlutterReduxApp(),
2424
));
2525
///屏幕刷新率和显示率不一致时的优化
2626
GestureBinding.instance.resamplingEnabled = true;

lib/page/home/home_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class _HomePageState extends State<HomePage> {
6666
return _dialogExitApp(context);
6767
},
6868
child: GSYTabBarWidget(
69-
drawer: HomeDrawer(),
69+
drawer: const HomeDrawer(),
7070
type: TabType.bottom,
7171
tabItems: tabs,
7272
tabViews: [

lib/page/issue/widget/issue_header_item.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,9 @@ class IssueHeaderViewModel {
182182
closedBy = issueMap.closeBy != null ? issueMap.closeBy!.login : "";
183183
locked = issueMap.locked;
184184
issueComment = issueMap.title;
185-
issueDesHtml = issueMap.bodyHtml != null
186-
? issueMap.bodyHtml
187-
: (issueMap.body != null)
185+
issueDesHtml = issueMap.bodyHtml ?? ((issueMap.body != null)
188186
? issueMap.body
189-
: "";
187+
: "");
190188
commentCount = "${issueMap.commentNum}";
191189
state = issueMap.state;
192190
issueDes = issueMap.body != null ? ": \n${issueMap.body!}" : '';

lib/page/login/login_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class _LoginPageState extends State<LoginPage> with LoginBLoC {
4242
body: Container(
4343
color: Theme.of(context).primaryColor,
4444
child: Stack(children: <Widget>[
45-
Positioned.fill(child: AnimatedBackground()),
46-
Positioned.fill(child: ParticlesWidget(30)),
45+
const Positioned.fill(child: AnimatedBackground()),
46+
const Positioned.fill(child: ParticlesWidget(30)),
4747
Center(
4848
///防止overFlow的现象
4949
child: SafeArea(

lib/page/repos/widget/repos_header_item.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ class ReposHeaderViewModel {
456456

457457
ReposHeaderViewModel();
458458

459-
ReposHeaderViewModel.fromHttpMap(ownerName, reposName, RepositoryQL? map) {
460-
this.ownerName = ownerName;
459+
ReposHeaderViewModel.fromHttpMap(this.ownerName, reposName, RepositoryQL? map) {
461460
if (map == null || map.ownerName == null) {
462461
return;
463462
}
@@ -479,7 +478,7 @@ class ReposHeaderViewModel {
479478
repositoryType = map.language;
480479
repositoryDes = map.shortDescriptionHTML;
481480
repositoryIsFork = map.isFork;
482-
license = map.license != null ? map.license : "";
481+
license = map.license ?? "";
483482
repositoryParentName =
484483
map.parent?.reposName;
485484
repositoryParentUser =

0 commit comments

Comments
 (0)