1
0
mirror of https://github.com/git-touch/git-touch synced 2025-03-26 08:00:05 +01:00

fix: nullable types

This commit is contained in:
Rongjian Zhang 2021-05-30 23:55:57 +08:00
parent 445925584b
commit 841a5d13cf
7 changed files with 17 additions and 23 deletions

View File

@ -191,20 +191,15 @@ class _HomeState extends State<Home> {
search,
me,
];
break;
case PlatformType.gitlab:
return [explore, group, search, me];
break;
case PlatformType.bitbucket:
return [explore, group, me];
break;
case PlatformType.gitea:
return [group, me];
break;
case PlatformType.gitee:
case PlatformType.gogs:
return [search, me];
break;
default:
return [];
}

View File

@ -26,7 +26,7 @@ class ListStatefulScaffold<T, K> extends StatefulWidget {
final Widget title;
final Widget Function()? actionBuilder;
final Widget Function(T payload) itemBuilder;
final Future<ListPayload<T, K>> Function(K cursor) fetch;
final Future<ListPayload<T, K>> Function(K? cursor) fetch;
ListStatefulScaffold({
required this.title,
@ -41,7 +41,7 @@ class ListStatefulScaffold<T, K> extends StatefulWidget {
}
class _ListStatefulScaffoldState<T, K>
extends State<ListStatefulScaffold<T, K?>> {
extends State<ListStatefulScaffold<T, K>> {
bool loading = false;
bool loadingMore = false;
String error = '';

View File

@ -7,7 +7,8 @@ class RefreshStatefulScaffold<T> extends StatefulWidget {
final Widget title;
final Widget? Function(T data, void Function(T newData) setData) bodyBuilder;
final Future<T> Function() fetch;
final Widget? Function(T data, void Function(T newData) setData)? actionBuilder;
final Widget? Function(T data, void Function(T newData) setData)?
actionBuilder;
final Widget? action;
final canRefresh;
@ -26,7 +27,7 @@ class RefreshStatefulScaffold<T> extends StatefulWidget {
}
class _RefreshStatefulScaffoldState<T>
extends State<RefreshStatefulScaffold<T?>> {
extends State<RefreshStatefulScaffold<T>> {
// bool _loading;
T? _data;
String _error = '';
@ -60,7 +61,7 @@ class _RefreshStatefulScaffoldState<T>
Widget? get _action {
if (widget.action != null) return widget.action;
if (widget.actionBuilder == null || _data == null) return null;
return widget.actionBuilder!(_data, (v) {
return widget.actionBuilder!(_data!, (v) {
setState(() {
_data = v;
});
@ -70,7 +71,7 @@ class _RefreshStatefulScaffoldState<T>
@override
Widget build(BuildContext context) {
Widget child = ErrorLoadingWrapper(
bodyBuilder: () => widget.bodyBuilder(_data, (v) {
bodyBuilder: () => widget.bodyBuilder(_data!, (v) {
setState(() {
_data = v;
});

View File

@ -22,7 +22,7 @@ class TabStatefulScaffold<T> extends StatefulWidget {
_TabStatefulScaffoldState<T> createState() => _TabStatefulScaffoldState();
}
class _TabStatefulScaffoldState<T> extends State<TabStatefulScaffold<T?>> {
class _TabStatefulScaffoldState<T> extends State<TabStatefulScaffold<T>> {
late bool _loading;
T? _payload0;
T? _payload1;
@ -90,7 +90,7 @@ class _TabStatefulScaffoldState<T> extends State<TabStatefulScaffold<T?>> {
title: widget.title,
action: widget.actionBuilder == null
? null
: widget.actionBuilder!(_payload, _refresh),
: widget.actionBuilder!(_payload!, _refresh),
tabs: widget.tabs,
activeTab: _activeTab,
onTabSwitch: (selected) async {
@ -105,7 +105,7 @@ class _TabStatefulScaffoldState<T> extends State<TabStatefulScaffold<T?>> {
},
onRefresh: _refresh,
body: ErrorLoadingWrapper(
bodyBuilder: () => widget.bodyBuilder(_payload, _activeTab),
bodyBuilder: () => widget.bodyBuilder(_payload!, _activeTab),
error: _error,
loading: _payload == null,
reload: _refresh,

View File

@ -20,7 +20,7 @@ class GhNotificationScreen extends StatefulWidget {
}
class GhNotificationScreenState extends State<GhNotificationScreen> {
Future<Map<String?, NotificationGroup>> fetchNotifications(int index) async {
Future<Map<String, NotificationGroup>> fetchNotifications(int index) async {
final ns = await context.read<AuthModel>().ghClient!.getJSON(
'/notifications?all=${index == 2}&participating=${index == 1}',
convert: (dynamic vs) =>
@ -30,10 +30,10 @@ class GhNotificationScreenState extends State<GhNotificationScreen> {
context.read<NotificationModel>().setCount(ns.length);
}
Map<String?, NotificationGroup> _groupMap = {};
Map<String, NotificationGroup> _groupMap = {};
ns.forEach((item) {
final repo = item.repository!.fullName;
final repo = item.repository!.fullName ?? ''; // TODO: nullable
if (_groupMap[repo] == null) {
_groupMap[repo] = NotificationGroup(repo);
}
@ -155,7 +155,7 @@ ${item.key}: pullRequest(number: ${item.subject!.number}) {
@override
Widget build(context) {
return TabStatefulScaffold(
return TabStatefulScaffold<Map<String, NotificationGroup>>(
title: AppBarTitle(AppLocalizations.of(context)!.notification),
tabs: [
AppLocalizations.of(context)!.unread,

View File

@ -42,7 +42,6 @@ class _NotificationItemState extends State<NotificationItem> {
default:
return _buildIcon(Octicons.person);
}
break;
case 'PullRequest':
switch (payload.state) {
case 'OPEN':
@ -54,7 +53,6 @@ class _NotificationItemState extends State<NotificationItem> {
default:
return _buildIcon(Octicons.person);
}
break;
// color: Color.fromRGBO(0x6f, 0x42, 0xc1, 1),
case 'Release':
return _buildIcon(Octicons.tag);

View File

@ -28,7 +28,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.6.1"
boolean_selector:
dependency: transitive
description:
@ -760,7 +760,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
@ -802,7 +802,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.3.0"
timeago:
dependency: "direct main"
description: