Skip to content

Commit 841a5d1

Browse files
committed
fix: nullable types
1 parent 4459255 commit 841a5d1

File tree

7 files changed

+17
-23
lines changed

7 files changed

+17
-23
lines changed

lib/home.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,15 @@ class _HomeState extends State<Home> {
191191
search,
192192
me,
193193
];
194-
break;
195194
case PlatformType.gitlab:
196195
return [explore, group, search, me];
197-
break;
198196
case PlatformType.bitbucket:
199197
return [explore, group, me];
200-
break;
201198
case PlatformType.gitea:
202199
return [group, me];
203-
break;
204200
case PlatformType.gitee:
205201
case PlatformType.gogs:
206202
return [search, me];
207-
break;
208203
default:
209204
return [];
210205
}

lib/scaffolds/list_stateful.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ListStatefulScaffold<T, K> extends StatefulWidget {
2626
final Widget title;
2727
final Widget Function()? actionBuilder;
2828
final Widget Function(T payload) itemBuilder;
29-
final Future<ListPayload<T, K>> Function(K cursor) fetch;
29+
final Future<ListPayload<T, K>> Function(K? cursor) fetch;
3030

3131
ListStatefulScaffold({
3232
required this.title,
@@ -41,7 +41,7 @@ class ListStatefulScaffold<T, K> extends StatefulWidget {
4141
}
4242

4343
class _ListStatefulScaffoldState<T, K>
44-
extends State<ListStatefulScaffold<T, K?>> {
44+
extends State<ListStatefulScaffold<T, K>> {
4545
bool loading = false;
4646
bool loadingMore = false;
4747
String error = '';

lib/scaffolds/refresh_stateful.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class RefreshStatefulScaffold<T> extends StatefulWidget {
77
final Widget title;
88
final Widget? Function(T data, void Function(T newData) setData) bodyBuilder;
99
final Future<T> Function() fetch;
10-
final Widget? Function(T data, void Function(T newData) setData)? actionBuilder;
10+
final Widget? Function(T data, void Function(T newData) setData)?
11+
actionBuilder;
1112
final Widget? action;
1213
final canRefresh;
1314

@@ -26,7 +27,7 @@ class RefreshStatefulScaffold<T> extends StatefulWidget {
2627
}
2728

2829
class _RefreshStatefulScaffoldState<T>
29-
extends State<RefreshStatefulScaffold<T?>> {
30+
extends State<RefreshStatefulScaffold<T>> {
3031
// bool _loading;
3132
T? _data;
3233
String _error = '';
@@ -60,7 +61,7 @@ class _RefreshStatefulScaffoldState<T>
6061
Widget? get _action {
6162
if (widget.action != null) return widget.action;
6263
if (widget.actionBuilder == null || _data == null) return null;
63-
return widget.actionBuilder!(_data, (v) {
64+
return widget.actionBuilder!(_data!, (v) {
6465
setState(() {
6566
_data = v;
6667
});
@@ -70,7 +71,7 @@ class _RefreshStatefulScaffoldState<T>
7071
@override
7172
Widget build(BuildContext context) {
7273
Widget child = ErrorLoadingWrapper(
73-
bodyBuilder: () => widget.bodyBuilder(_data, (v) {
74+
bodyBuilder: () => widget.bodyBuilder(_data!, (v) {
7475
setState(() {
7576
_data = v;
7677
});

lib/scaffolds/tab_stateful.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TabStatefulScaffold<T> extends StatefulWidget {
2222
_TabStatefulScaffoldState<T> createState() => _TabStatefulScaffoldState();
2323
}
2424

25-
class _TabStatefulScaffoldState<T> extends State<TabStatefulScaffold<T?>> {
25+
class _TabStatefulScaffoldState<T> extends State<TabStatefulScaffold<T>> {
2626
late bool _loading;
2727
T? _payload0;
2828
T? _payload1;
@@ -90,7 +90,7 @@ class _TabStatefulScaffoldState<T> extends State<TabStatefulScaffold<T?>> {
9090
title: widget.title,
9191
action: widget.actionBuilder == null
9292
? null
93-
: widget.actionBuilder!(_payload, _refresh),
93+
: widget.actionBuilder!(_payload!, _refresh),
9494
tabs: widget.tabs,
9595
activeTab: _activeTab,
9696
onTabSwitch: (selected) async {
@@ -105,7 +105,7 @@ class _TabStatefulScaffoldState<T> extends State<TabStatefulScaffold<T?>> {
105105
},
106106
onRefresh: _refresh,
107107
body: ErrorLoadingWrapper(
108-
bodyBuilder: () => widget.bodyBuilder(_payload, _activeTab),
108+
bodyBuilder: () => widget.bodyBuilder(_payload!, _activeTab),
109109
error: _error,
110110
loading: _payload == null,
111111
reload: _refresh,

lib/screens/gh_notification.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GhNotificationScreen extends StatefulWidget {
2020
}
2121

2222
class GhNotificationScreenState extends State<GhNotificationScreen> {
23-
Future<Map<String?, NotificationGroup>> fetchNotifications(int index) async {
23+
Future<Map<String, NotificationGroup>> fetchNotifications(int index) async {
2424
final ns = await context.read<AuthModel>().ghClient!.getJSON(
2525
'/notifications?all=${index == 2}&participating=${index == 1}',
2626
convert: (dynamic vs) =>
@@ -30,10 +30,10 @@ class GhNotificationScreenState extends State<GhNotificationScreen> {
3030
context.read<NotificationModel>().setCount(ns.length);
3131
}
3232

33-
Map<String?, NotificationGroup> _groupMap = {};
33+
Map<String, NotificationGroup> _groupMap = {};
3434

3535
ns.forEach((item) {
36-
final repo = item.repository!.fullName;
36+
final repo = item.repository!.fullName ?? ''; // TODO: nullable
3737
if (_groupMap[repo] == null) {
3838
_groupMap[repo] = NotificationGroup(repo);
3939
}
@@ -155,7 +155,7 @@ ${item.key}: pullRequest(number: ${item.subject!.number}) {
155155

156156
@override
157157
Widget build(context) {
158-
return TabStatefulScaffold(
158+
return TabStatefulScaffold<Map<String, NotificationGroup>>(
159159
title: AppBarTitle(AppLocalizations.of(context)!.notification),
160160
tabs: [
161161
AppLocalizations.of(context)!.unread,

lib/widgets/notification_item.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class _NotificationItemState extends State<NotificationItem> {
4242
default:
4343
return _buildIcon(Octicons.person);
4444
}
45-
break;
4645
case 'PullRequest':
4746
switch (payload.state) {
4847
case 'OPEN':
@@ -54,7 +53,6 @@ class _NotificationItemState extends State<NotificationItem> {
5453
default:
5554
return _buildIcon(Octicons.person);
5655
}
57-
break;
5856
// color: Color.fromRGBO(0x6f, 0x42, 0xc1, 1),
5957
case 'Release':
6058
return _buildIcon(Octicons.tag);

pubspec.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ packages:
2828
name: async
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "2.5.0"
31+
version: "2.6.1"
3232
boolean_selector:
3333
dependency: transitive
3434
description:
@@ -760,7 +760,7 @@ packages:
760760
name: source_span
761761
url: "https://pub.dartlang.org"
762762
source: hosted
763-
version: "1.8.0"
763+
version: "1.8.1"
764764
stack_trace:
765765
dependency: transitive
766766
description:
@@ -802,7 +802,7 @@ packages:
802802
name: test_api
803803
url: "https://pub.dartlang.org"
804804
source: hosted
805-
version: "0.2.19"
805+
version: "0.3.0"
806806
timeago:
807807
dependency: "direct main"
808808
description:

0 commit comments

Comments
 (0)