mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-21 01:05:18 +00:00
Start to fix null safety migration errors
This commit is contained in:
@ -50,7 +50,7 @@ abstract class MainController extends State<MainRoute> {
|
||||
int get numberOfPages => _pagesStack.length;
|
||||
|
||||
/// Get current instance of Home controller
|
||||
static MainController of(BuildContext context) {
|
||||
static MainController? of(BuildContext context) {
|
||||
assert(context != null); // A future implementation might need context again
|
||||
return mainControllerKey.currentState;
|
||||
}
|
||||
@ -75,7 +75,7 @@ abstract class MainController extends State<MainRoute> {
|
||||
|
||||
/// Pop until main route is reached
|
||||
void popUntilMainRoute() => Navigator.of(context).popUntil((settings) =>
|
||||
ModalRoute.of(context).isCurrent || !ModalRoute.of(context).isActive);
|
||||
ModalRoute.of(context)!.isCurrent || !ModalRoute.of(context)!.isActive);
|
||||
|
||||
/// Go to the previous page (use for [WillPop] widget)
|
||||
@protected
|
||||
@ -109,13 +109,13 @@ abstract class MainController extends State<MainRoute> {
|
||||
pushPage(PageInfo(child: UserAccessDeniedScreen(userID: userID)));
|
||||
|
||||
/// Open current user page
|
||||
void openCurrentUserPage() => this.openUserPage(userID());
|
||||
void openCurrentUserPage() => this.openUserPage(userID()!);
|
||||
|
||||
/// Open a specific group page specified by its [groupID]
|
||||
///
|
||||
/// [conversationID] is an optional parameter specifying a conversation
|
||||
/// that should be opened instead of posts thread
|
||||
void openGroup(int groupID, {int conversationID}) => pushPage(PageInfo(
|
||||
void openGroup(int groupID, {int? conversationID}) => pushPage(PageInfo(
|
||||
type: PageType.GROUP_PAGE,
|
||||
child: GroupPageScreen(
|
||||
groupID: groupID,
|
||||
@ -137,10 +137,10 @@ abstract class MainController extends State<MainRoute> {
|
||||
void openGroupsListPage() => pushPage(PageInfo(child: GroupsListScreen()));
|
||||
|
||||
/// Display the list of friends of a user
|
||||
void openUserFriendsList(int id) {
|
||||
void openUserFriendsList(int? id) {
|
||||
if (id != userID())
|
||||
pushPage(PageInfo(
|
||||
child: OtherUserFriendsListScreen(userID: id),
|
||||
child: OtherUserFriendsListScreen(userID: id!),
|
||||
canShowAsDialog: true,
|
||||
));
|
||||
else
|
||||
@ -156,9 +156,9 @@ abstract class MainController extends State<MainRoute> {
|
||||
/// Open a conversation in its context (in group page for group conversations)
|
||||
void openConversation(Conversation conv, {fullScreen: false}) {
|
||||
if (conv.isGroupConversation)
|
||||
openGroup(conv.groupID, conversationID: conv.id);
|
||||
openGroup(conv.groupID!, conversationID: conv.id);
|
||||
else
|
||||
openConversationById(conv.id, fullScreen: fullScreen);
|
||||
openConversationById(conv.id!, fullScreen: fullScreen);
|
||||
}
|
||||
|
||||
/// Open a conversation
|
||||
@ -173,7 +173,7 @@ abstract class MainController extends State<MainRoute> {
|
||||
/// Open conversation settings route
|
||||
void openConversationSettingsRoute(Conversation conv) => pushPage(PageInfo(
|
||||
child: UpdateConversationRoute(
|
||||
conversationID: conv.id,
|
||||
conversationID: conv.id!,
|
||||
),
|
||||
canShowAsDialog: true,
|
||||
hideNavBar: true,
|
||||
@ -215,7 +215,7 @@ abstract class MainController extends State<MainRoute> {
|
||||
///
|
||||
/// If the current route is not the main route, we pop one page
|
||||
void popPage() {
|
||||
if (!ModalRoute.of(context).isCurrent)
|
||||
if (!ModalRoute.of(context)!.isCurrent)
|
||||
Navigator.of(context).pop();
|
||||
else
|
||||
doPopPage();
|
||||
|
@ -18,7 +18,7 @@ enum PageType {
|
||||
class PageInfo {
|
||||
final PageType type;
|
||||
final Widget child;
|
||||
final int id;
|
||||
final int? id;
|
||||
final bool hideNavBar;
|
||||
final bool canShowAsDialog;
|
||||
|
||||
@ -27,7 +27,7 @@ class PageInfo {
|
||||
|
||||
PageInfo({
|
||||
this.type = PageType.OTHER_PAGE,
|
||||
@required this.child,
|
||||
required this.child,
|
||||
this.id,
|
||||
this.hideNavBar = false,
|
||||
this.canShowAsDialog = false,
|
||||
|
@ -10,7 +10,7 @@ import 'package:flutter/material.dart';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class SmartphoneMainRoute extends StatefulWidget implements MainRoute {
|
||||
const SmartphoneMainRoute({Key key}) : super(key: key);
|
||||
const SmartphoneMainRoute({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _MainRouteState();
|
||||
|
@ -19,7 +19,7 @@ import 'package:flutter/material.dart';
|
||||
const _SideBarSize = 300.0;
|
||||
|
||||
class TabletRoute extends StatefulWidget implements MainRoute {
|
||||
const TabletRoute({Key key}) : super(key: key);
|
||||
const TabletRoute({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_TabletRouteState createState() => _TabletRouteState();
|
||||
@ -37,7 +37,7 @@ class _TabletRouteState extends MainController {
|
||||
return WillPopScope(
|
||||
onWillPop: willPop,
|
||||
child: Scaffold(
|
||||
appBar: _buildAppBar(),
|
||||
appBar: _buildAppBar() as PreferredSizeWidget?,
|
||||
body: _buildBody(),
|
||||
),
|
||||
);
|
||||
@ -105,14 +105,14 @@ class _TabletRouteState extends MainController {
|
||||
}
|
||||
|
||||
@override
|
||||
void openConversationById(int convID, {fullScreen = false}) {
|
||||
void openConversationById(int? convID, {fullScreen = false}) {
|
||||
if (!fullScreen) {
|
||||
popUntilMainRoute();
|
||||
_conversationsKey.currentState.openConversations(convID);
|
||||
_conversationsKey.currentState!.openConversations(convID);
|
||||
} else
|
||||
super.openConversationById(convID, fullScreen: fullScreen);
|
||||
super.openConversationById(convID!, fullScreen: fullScreen);
|
||||
}
|
||||
|
||||
@override
|
||||
void startCall(int convID) => _callsKey.currentState.openCall(convID);
|
||||
void startCall(int convID) => _callsKey.currentState!.openCall(convID);
|
||||
}
|
||||
|
Reference in New Issue
Block a user