1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-20 16:55:17 +00:00

Start to fix null safety migration errors

This commit is contained in:
2022-03-10 19:39:57 +01:00
parent ab2c5da0da
commit 3a997cdc56
258 changed files with 2879 additions and 2912 deletions

View File

@ -12,7 +12,7 @@ import 'package:flutter/material.dart';
///
/// @author Pierre HUBERT
typedef OnSelectMenuAction = void Function(BarCallbackActions);
typedef OnSelectMenuAction = void Function(BarCallbackActions?);
/// Callback actions
enum BarCallbackActions {
@ -35,15 +35,15 @@ Color _secondaryColor() => darkTheme() ? darkAccentColor : Colors.white;
class _MenuItem {
final String label;
final Widget icon;
final BarCallbackActions action;
final BarCallbackActions? action;
final bool isMenu;
final PageType pageType;
final PageType? pageType;
const _MenuItem({
@required this.label,
@required this.icon,
@required this.action,
@required this.pageType,
required this.label,
required this.icon,
required this.action,
required this.pageType,
this.isMenu = false,
}) : assert(label != null),
assert(isMenu != null),
@ -57,7 +57,7 @@ class _ActionMenuItem {
final String label;
final BarCallbackActions action;
const _ActionMenuItem({@required this.label, @required this.action})
const _ActionMenuItem({required this.label, required this.action})
: assert(label != null),
assert(action != null);
}
@ -65,27 +65,27 @@ class _ActionMenuItem {
/// List of menu items to show
final _menuItems = <_MenuItem>[
_MenuItem(
label: tr("Notifications"),
label: tr("Notifications")!,
icon: Icon(Icons.notifications),
action: BarCallbackActions.OPEN_NOTIFICATIONS,
pageType: PageType.NOTIFICATIONS_PAGE),
_MenuItem(
label: tr("Conversations"),
label: tr("Conversations")!,
icon: Icon(Icons.comment),
action: BarCallbackActions.OPEN_CONVERSATIONS,
pageType: PageType.CONVERSATIONS_LIST_PAGE),
_MenuItem(
label: tr("Newest"),
label: tr("Newest")!,
icon: Icon(Icons.refresh),
action: BarCallbackActions.OPEN_NEWEST_POSTS,
pageType: PageType.LATEST_POSTS_PAGE),
_MenuItem(
label: tr("Friends"),
label: tr("Friends")!,
icon: Icon(Icons.group),
action: BarCallbackActions.OPEN_FRIENDS,
pageType: PageType.FRIENDS_LIST_PAGE),
_MenuItem(
label: tr("Menu"),
label: tr("Menu")!,
icon: Icon(Icons.more_vert),
isMenu: true,
action: null,
@ -95,14 +95,14 @@ final _menuItems = <_MenuItem>[
/// List of menu actions items
final _menuActionsItem = <_ActionMenuItem>[
_ActionMenuItem(
label: tr("My Page"), action: BarCallbackActions.OPEN_MY_PAGE),
_ActionMenuItem(label: tr("Groups"), action: BarCallbackActions.OPEN_GROUPS),
label: tr("My Page")!, action: BarCallbackActions.OPEN_MY_PAGE),
_ActionMenuItem(label: tr("Groups")!, action: BarCallbackActions.OPEN_GROUPS),
_ActionMenuItem(
label: tr("Search"), action: BarCallbackActions.OPEN_SEARCH_PAGE),
label: tr("Search")!, action: BarCallbackActions.OPEN_SEARCH_PAGE),
_ActionMenuItem(
label: tr("Settings"), action: BarCallbackActions.OPEN_SETTINGS),
label: tr("Settings")!, action: BarCallbackActions.OPEN_SETTINGS),
_ActionMenuItem(
label: tr("Sign out"), action: BarCallbackActions.ACTION_LOGOUT),
label: tr("Sign out")!, action: BarCallbackActions.ACTION_LOGOUT),
];
/// Public widget
@ -111,8 +111,8 @@ class ComunicMobileAppBar extends StatefulWidget
final PageInfo currentPage;
const ComunicMobileAppBar({
Key key,
@required this.currentPage,
Key? key,
required this.currentPage,
}) : assert(currentPage != null),
super(key: key);
@ -153,7 +153,7 @@ class _ComunicMobileAppBarState extends SafeState<ComunicMobileAppBar> {
}
/// Get the number of unread notifications for the selected notice
int getNumberUnread(BarCallbackActions action) {
int? getNumberUnread(BarCallbackActions? action) {
if (_unreadNotifications == null) return 0;
switch (action) {
@ -187,35 +187,35 @@ class _ComunicMobileAppBarState extends SafeState<ComunicMobileAppBar> {
);
}
void _handleAction(BarCallbackActions action) {
void _handleAction(BarCallbackActions? action) {
final controller = MainController.of(context);
switch (action) {
case BarCallbackActions.OPEN_NOTIFICATIONS:
controller.openNotificationsPage();
controller!.openNotificationsPage();
break;
case BarCallbackActions.OPEN_CONVERSATIONS:
controller.openConversationsPage();
controller!.openConversationsPage();
break;
case BarCallbackActions.OPEN_NEWEST_POSTS:
controller.openLatestPostsPage();
controller!.openLatestPostsPage();
break;
case BarCallbackActions.OPEN_FRIENDS:
controller.openFriendsList();
controller!.openFriendsList();
break;
case BarCallbackActions.OPEN_MY_PAGE:
controller.openCurrentUserPage();
controller!.openCurrentUserPage();
break;
case BarCallbackActions.OPEN_SEARCH_PAGE:
controller.openSearchPage();
controller!.openSearchPage();
break;
case BarCallbackActions.OPEN_GROUPS:
controller.openGroupsListPage();
controller!.openGroupsListPage();
break;
case BarCallbackActions.OPEN_SETTINGS:
controller.openSettings();
controller!.openSettings();
break;
case BarCallbackActions.ACTION_LOGOUT:
controller.requestLogout();
controller!.requestLogout();
break;
}
}
@ -228,18 +228,15 @@ class _MenuItemWidget extends StatelessWidget {
final bool isSelected;
/// Notifications notice
final int newNotice;
final int? newNotice;
const _MenuItemWidget({
Key key,
@required this.item,
@required this.onTap,
@required this.isSelected,
Key? key,
required this.item,
required this.onTap,
required this.isSelected,
this.newNotice = 0,
}) : assert(item != null),
assert(onTap != null),
assert(isSelected != null),
super(key: key);
}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -269,7 +266,7 @@ class _MenuItemWidget extends StatelessWidget {
color: isSelected ? _primaryColor() : _secondaryColor()),
child: item.icon,
),
newNotice > 0 ? Spacer() : Container(),
newNotice! > 0 ? Spacer() : Container(),
newNotice == 0
? Container()
: Material(

View File

@ -16,9 +16,9 @@ class UserMobilePage extends StatefulWidget {
final void Function() onNeedRefresh;
const UserMobilePage({
Key key,
@required this.userInfo,
@required this.onNeedRefresh,
Key? key,
required this.userInfo,
required this.onNeedRefresh,
}) : assert(userInfo != null),
assert(onNeedRefresh != null),
super(key: key);
@ -29,12 +29,12 @@ class UserMobilePage extends StatefulWidget {
class _UserMobilePageState extends State<UserMobilePage>
with SingleTickerProviderStateMixin {
TabController _tabController;
TabController? _tabController;
List<UserPageTab> get _tabs => [
// User posts
UserPageTab(
label: tr("Posts"),
label: tr("Posts")!,
onBuild: (c) => UserPostsSection(
user: widget.userInfo,
),
@ -42,13 +42,13 @@ class _UserMobilePageState extends State<UserMobilePage>
// About user
UserPageTab(
label: tr("About"),
label: tr("About")!,
onBuild: (c) => AboutUserSection(user: widget.userInfo),
),
// User friends
UserPageTab(
label: tr("Friends"),
label: tr("Friends")!,
onBuild: (c) => widget.userInfo.isCurrentUser
? FriendsListScreen(
showAppBar: false,
@ -70,7 +70,7 @@ class _UserMobilePageState extends State<UserMobilePage>
@override
void dispose() {
_tabController.dispose();
_tabController!.dispose();
super.dispose();
}
@ -111,8 +111,8 @@ class UserPageTab {
final bool visible;
UserPageTab({
@required this.label,
@required this.onBuild,
required this.label,
required this.onBuild,
this.visible = true,
}) : assert(label != null),
assert(onBuild != null),