Skip to content

Commit ac02fd7

Browse files
committed
refactor: use null operators
1 parent 17b6fd5 commit ac02fd7

File tree

7 files changed

+21
-28
lines changed

7 files changed

+21
-28
lines changed

lib/scaffolds/list_stateful.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class _ListStatefulScaffoldState<T, K>
213213
return CommonScaffold(
214214
title: widget.title,
215215
body: _buildBody(),
216-
action: widget.actionBuilder == null ? null : widget.actionBuilder!(),
216+
action: widget.actionBuilder?.call(),
217217
);
218218
}
219219
}

lib/screens/bb_repo.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class BbRepoScreen extends StatelessWidget {
6464
text: Text('Code'),
6565
rightWidget: Text(filesize(p.size)),
6666
url:
67-
'/bitbucket/$owner/$name/src/${branch == null ? p.mainbranch!.name : branch}',
67+
'/bitbucket/$owner/$name/src/${branch ?? p.mainbranch!.name}',
6868
),
6969
TableViewItem(
7070
leftIconData: Octicons.issue_opened,
@@ -80,16 +80,15 @@ class BbRepoScreen extends StatelessWidget {
8080
leftIconData: Octicons.history,
8181
text: Text('Commits'),
8282
url:
83-
'/bitbucket/$owner/$name/commits/${branch == null ? p.mainbranch!.name : branch}',
83+
'/bitbucket/$owner/$name/commits/${branch ?? p.mainbranch!.name}',
8484
),
8585
if (branches != null)
8686
TableViewItem(
8787
leftIconData: Octicons.git_branch,
8888
text: Text(AppLocalizations.of(context)!.branches),
89-
rightWidget: Text(
90-
(branch == null ? p.mainbranch!.name : branch)! +
91-
' • ' +
92-
branches.length.toString()),
89+
rightWidget: Text((branch ?? p.mainbranch!.name)! +
90+
' • ' +
91+
branches.length.toString()),
9392
onTap: () async {
9493
if (branches.length < 2) return;
9594

lib/screens/ge_repo.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ class GeRepoScreen extends StatelessWidget {
139139
leftIconData: Octicons.code,
140140
text: Text('Code'),
141141
rightWidget: Text(p.license ?? ''),
142-
url:
143-
'/gitee/$owner/$name/tree/${branch == null ? p.defaultBranch : branch}',
142+
url: '/gitee/$owner/$name/tree/${branch ?? p.defaultBranch}',
144143
),
145144
TableViewItem(
146145
leftIconData: Octicons.issue_opened,
@@ -158,16 +157,15 @@ class GeRepoScreen extends StatelessWidget {
158157
leftIconData: Octicons.history,
159158
text: Text('Commits'),
160159
url:
161-
'/gitee/$owner/$name/commits?branch=${branch == null ? p.defaultBranch : branch}',
160+
'/gitee/$owner/$name/commits?branch=${branch ?? p.defaultBranch}',
162161
),
163162
if (branches != null)
164163
TableViewItem(
165164
leftIconData: Octicons.git_branch,
166165
text: Text(AppLocalizations.of(context)!.branches),
167-
rightWidget: Text(
168-
(branch == null ? p.defaultBranch : branch)! +
169-
' • ' +
170-
branches.length.toString()),
166+
rightWidget: Text((branch ?? p.defaultBranch)! +
167+
' • ' +
168+
branches.length.toString()),
171169
onTap: () async {
172170
if (branches.length < 2) return;
173171

lib/screens/gh_object.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class GhObjectScreen extends StatelessWidget {
2222
Widget build(BuildContext context) {
2323
return RefreshStatefulScaffold<RepositoryContents>(
2424
// canRefresh: !_isImage, // TODO:
25-
title: AppBarTitle(path == null ? 'Files' : path),
25+
title: AppBarTitle(path ?? 'Files'),
2626
fetch: () async {
2727
// Do not request again for images
2828
if (path != null &&

lib/screens/gl_project.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,16 @@ class GlProjectScreen extends StatelessWidget {
199199
? null
200200
: Text(p.statistics!.commitCount.toString()),
201201
url:
202-
'/gitlab/projects/$id/commits?prefix=$prefix&branch=${branch == null ? p.defaultBranch : branch}', // EDIT
202+
'/gitlab/projects/$id/commits?prefix=$prefix&branch=${branch ?? p.defaultBranch}', // EDIT
203203
),
204204
if (branches != null)
205205
TableViewItem(
206206
leftIconData: Octicons.git_branch,
207207
text: Text(AppLocalizations.of(context)!.branches),
208-
rightWidget: Text(
209-
((branch == null ? p.defaultBranch : branch) ??
210-
'' /** empty project */) +
211-
' • ' +
212-
branches.length.toString()),
208+
rightWidget: Text(((branch ?? p.defaultBranch) ??
209+
'' /** empty project */) +
210+
' • ' +
211+
branches.length.toString()),
213212
onTap: () async {
214213
if (branches.length < 2) return;
215214

lib/screens/go_object.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ class GoObjectScreen extends StatelessWidget {
5757
]);
5858
} else {
5959
final v = GogsBlob.fromJson(p);
60-
return BlobView(v.name,
61-
base64Text: v.content == null ? '' : v.content);
60+
return BlobView(v.name, base64Text: v.content);
6261
}
6362
},
6463
);

lib/screens/go_repo.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ class GoRepoScreen extends StatelessWidget {
9494
TableViewItem(
9595
leftIconData: Octicons.code,
9696
text: Text('Code'),
97-
url:
98-
'/gogs/$owner/$name/blob?ref=${branch == null ? 'master' : branch}',
97+
url: '/gogs/$owner/$name/blob?ref=${branch ?? 'master'}',
9998
),
10099
TableViewItem(
101100
leftIconData: Octicons.issue_opened,
@@ -110,13 +109,12 @@ class GoRepoScreen extends StatelessWidget {
110109
TableViewItem(
111110
leftIconData: Octicons.history,
112111
text: Text('Commits'),
113-
url:
114-
'/gogs/$owner/$name/commits?ref=${branch == null ? 'master' : branch}',
112+
url: '/gogs/$owner/$name/commits?ref=${branch ?? 'master'}',
115113
),
116114
TableViewItem(
117115
leftIconData: Octicons.git_branch,
118116
text: Text(AppLocalizations.of(context)!.branches),
119-
rightWidget: Text((branch == null ? 'master' : branch)! +
117+
rightWidget: Text((branch ?? 'master')! +
120118
' • ' +
121119
'${branches == null ? '1' : branches.length.toString()}'),
122120
onTap: () async {

0 commit comments

Comments
 (0)