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:
@ -24,8 +24,8 @@ class ForezMemberProfileRoute extends StatefulWidget {
|
||||
final int userID;
|
||||
|
||||
const ForezMemberProfileRoute({
|
||||
Key key,
|
||||
@required this.userID,
|
||||
Key? key,
|
||||
required this.userID,
|
||||
}) : assert(userID != null),
|
||||
super(key: key);
|
||||
|
||||
@ -39,13 +39,13 @@ class _ForezMemberProfileRouteState extends State<ForezMemberProfileRoute> {
|
||||
|
||||
final _key = GlobalKey<AsyncScreenWidgetState>();
|
||||
|
||||
AdvancedUserInfo _user;
|
||||
PresenceSet _presence;
|
||||
late AdvancedUserInfo _user;
|
||||
late PresenceSet _presence;
|
||||
|
||||
Future<void> _load() async {
|
||||
_user = await ForezGroupsHelper.getMemberInfo(forezGroup.id, widget.userID);
|
||||
_user = await ForezGroupsHelper.getMemberInfo(forezGroup!.id, widget.userID);
|
||||
_presence =
|
||||
await ForezPresenceHelper.getForUser(forezGroup.id, widget.userID);
|
||||
await ForezPresenceHelper.getForUser(forezGroup!.id, widget.userID);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -56,25 +56,25 @@ class _ForezMemberProfileRouteState extends State<ForezMemberProfileRoute> {
|
||||
loadingWidget: _buildLoading(),
|
||||
errorWidget: _buildError(),
|
||||
errorMessage: tr(
|
||||
"Failed to load user information, maybe it is not a Forez member yet?"));
|
||||
"Failed to load user information, maybe it is not a Forez member yet?")!);
|
||||
|
||||
Widget _buildLoading() => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(tr("Loading...")),
|
||||
title: Text(tr("Loading...")!),
|
||||
),
|
||||
body: buildCenteredProgressBar(),
|
||||
);
|
||||
|
||||
Widget _buildError() => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(tr("Error")),
|
||||
title: Text(tr("Error")!),
|
||||
),
|
||||
body: buildErrorCard(
|
||||
tr("Failed to load user information, maybe it is not a Forez member yet?"),
|
||||
actions: [
|
||||
MaterialButton(
|
||||
onPressed: () => _key.currentState.refresh(),
|
||||
child: Text(tr("Try again")),
|
||||
onPressed: () => _key.currentState!.refresh(),
|
||||
child: Text(tr("Try again")!),
|
||||
textColor: Colors.white,
|
||||
)
|
||||
]),
|
||||
@ -101,7 +101,7 @@ class _ForezMemberProfileRouteState extends State<ForezMemberProfileRoute> {
|
||||
? Container()
|
||||
: CachedNetworkImage(
|
||||
fit: BoxFit.cover,
|
||||
imageUrl: _user.accountImageURL,
|
||||
imageUrl: _user.accountImageURL!,
|
||||
height: _appBarHeight,
|
||||
),
|
||||
// This gradient ensures that the toolbar icons are distinct
|
||||
@ -135,7 +135,7 @@ class _ForezMemberProfileRouteState extends State<ForezMemberProfileRoute> {
|
||||
: ListTile(
|
||||
leading: Icon(Icons.note),
|
||||
title: TextWidget(content: DisplayedString(_user.publicNote)),
|
||||
subtitle: Text(tr("Note")),
|
||||
subtitle: Text(tr("Note")!),
|
||||
),
|
||||
|
||||
// Email address
|
||||
@ -143,9 +143,9 @@ class _ForezMemberProfileRouteState extends State<ForezMemberProfileRoute> {
|
||||
? Container()
|
||||
: ListTile(
|
||||
leading: Icon(Icons.email),
|
||||
title: Text(_user.emailAddress),
|
||||
subtitle: Text(tr("Email address")),
|
||||
trailing: CopyIcon(_user.emailAddress),
|
||||
title: Text(_user.emailAddress!),
|
||||
subtitle: Text(tr("Email address")!),
|
||||
trailing: CopyIcon(_user.emailAddress!),
|
||||
),
|
||||
|
||||
// Location
|
||||
@ -153,9 +153,9 @@ class _ForezMemberProfileRouteState extends State<ForezMemberProfileRoute> {
|
||||
? Container()
|
||||
: ListTile(
|
||||
leading: Icon(Icons.location_on),
|
||||
title: Text(_user.location),
|
||||
subtitle: Text(tr("Location")),
|
||||
trailing: CopyIcon(_user.location),
|
||||
title: Text(_user.location!),
|
||||
subtitle: Text(tr("Location")!),
|
||||
trailing: CopyIcon(_user.location!),
|
||||
),
|
||||
|
||||
// Website
|
||||
@ -164,7 +164,7 @@ class _ForezMemberProfileRouteState extends State<ForezMemberProfileRoute> {
|
||||
: ListTile(
|
||||
leading: Icon(Icons.link),
|
||||
title: Text(_user.personalWebsite),
|
||||
subtitle: Text(tr("Website")),
|
||||
subtitle: Text(tr("Website")!),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.open_in_new),
|
||||
onPressed: () => launch(_user.personalWebsite),
|
||||
@ -174,10 +174,10 @@ class _ForezMemberProfileRouteState extends State<ForezMemberProfileRoute> {
|
||||
Divider(),
|
||||
ListTile(
|
||||
leading: Icon(Icons.calendar_today),
|
||||
title: Text(tr("Presence in Forez")),
|
||||
title: Text(tr("Presence in Forez")!),
|
||||
subtitle: Text(_presence.containsDate(DateTime.now())
|
||||
? tr("Present today")
|
||||
: tr("Absent")),
|
||||
? tr("Present today")!
|
||||
: tr("Absent")!),
|
||||
),
|
||||
PresenceCalendarWidget(presenceSet: _presence),
|
||||
Divider(),
|
||||
|
@ -21,7 +21,7 @@ import 'package:flutter/material.dart';
|
||||
/// @author Pierre Hubert
|
||||
|
||||
class ForezRoute extends StatefulWidget implements MainRoute {
|
||||
const ForezRoute({Key key}) : super(key: key);
|
||||
const ForezRoute({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _MainRouteState();
|
||||
@ -40,7 +40,7 @@ class _MainRouteState extends MainController {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (forezGroup == null) return Text(tr("Missing Forez group!"));
|
||||
if (forezGroup == null) return Text(tr("Missing Forez group!")!);
|
||||
|
||||
return StatusWidget(
|
||||
child: (c) => SafeArea(
|
||||
@ -67,11 +67,11 @@ class _MainRouteState extends MainController {
|
||||
@override
|
||||
void openConversation(Conversation conv, {fullScreen: false}) {
|
||||
// Forcefully open conversations in a "normal" way (do not display groups)
|
||||
openConversationById(conv.id, fullScreen: fullScreen);
|
||||
openConversationById(conv.id!, fullScreen: fullScreen);
|
||||
}
|
||||
|
||||
@override
|
||||
void openGroup(int groupID, {int conversationID}) => _unsupportedFeature();
|
||||
void openGroup(int groupID, {int? conversationID}) => _unsupportedFeature();
|
||||
|
||||
@override
|
||||
void openUserPage(int userID) => pushPage(PageInfo(
|
||||
@ -92,7 +92,7 @@ class _MainRouteState extends MainController {
|
||||
enum _PopupMenuItems { ACTION_SETTINGS, ACTION_SIGN_OUT }
|
||||
|
||||
class ForezRouteBody extends StatefulWidget {
|
||||
ForezRouteBody({Key key}) : super(key: key);
|
||||
ForezRouteBody({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ForezRouteBodyState createState() => _ForezRouteBodyState();
|
||||
@ -112,7 +112,7 @@ class _ForezRouteBodyState extends SafeState<ForezRouteBody> {
|
||||
length: _tabs.length,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(forezGroup.name),
|
||||
title: Text(forezGroup!.name),
|
||||
actions: <Widget>[_buildPopupMenuButton()],
|
||||
bottom: TabBar(tabs: _tabs),
|
||||
),
|
||||
@ -129,11 +129,11 @@ class _ForezRouteBodyState extends SafeState<ForezRouteBody> {
|
||||
Widget _buildPopupMenuButton() => PopupMenuButton<_PopupMenuItems>(
|
||||
itemBuilder: (c) => [
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Settings")),
|
||||
child: Text(tr("Settings")!),
|
||||
value: _PopupMenuItems.ACTION_SETTINGS,
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Sign out")),
|
||||
child: Text(tr("Sign out")!),
|
||||
value: _PopupMenuItems.ACTION_SIGN_OUT,
|
||||
),
|
||||
],
|
||||
@ -143,10 +143,10 @@ class _ForezRouteBodyState extends SafeState<ForezRouteBody> {
|
||||
void _onMenuSelection(_PopupMenuItems value) {
|
||||
switch (value) {
|
||||
case _PopupMenuItems.ACTION_SETTINGS:
|
||||
MainController.of(context).openSettings();
|
||||
MainController.of(context)!.openSettings();
|
||||
break;
|
||||
case _PopupMenuItems.ACTION_SIGN_OUT:
|
||||
MainController.of(context).requestLogout();
|
||||
MainController.of(context)!.requestLogout();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -155,29 +155,29 @@ class _ForezRouteBodyState extends SafeState<ForezRouteBody> {
|
||||
// Posts tab
|
||||
_Tab(
|
||||
icon: Icons.auto_stories,
|
||||
title: tr("Posts"),
|
||||
widget: () => GroupPostsSection(group: forezGroup),
|
||||
title: tr("Posts")!,
|
||||
widget: () => GroupPostsSection(group: forezGroup!),
|
||||
),
|
||||
|
||||
// Presence tab
|
||||
_Tab(
|
||||
icon: Icons.calendar_today,
|
||||
title: tr("Presence"),
|
||||
widget: () => ForezPresenceSection(groupID: forezGroup.id),
|
||||
title: tr("Presence")!,
|
||||
widget: () => ForezPresenceSection(groupID: forezGroup!.id),
|
||||
),
|
||||
|
||||
// Conversations tab
|
||||
_Tab(
|
||||
icon: Icons.question_answer,
|
||||
title: tr("Conversations"),
|
||||
title: tr("Conversations")!,
|
||||
widget: () => ConversationsListScreen(),
|
||||
isUnread: (c) => StatusWidgetState.of(c).unreadConversations > 0,
|
||||
isUnread: (c) => StatusWidgetState.of(c)!.unreadConversations! > 0,
|
||||
),
|
||||
|
||||
// Directory tab
|
||||
_Tab(
|
||||
icon: Icons.import_contacts,
|
||||
title: tr("Directory"),
|
||||
title: tr("Directory")!,
|
||||
widget: () => ForezDirectoryScreen(),
|
||||
),
|
||||
];
|
||||
@ -203,12 +203,12 @@ class _Tab {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final Widget Function() widget;
|
||||
final bool Function(BuildContext) isUnread;
|
||||
final bool Function(BuildContext)? isUnread;
|
||||
|
||||
const _Tab({
|
||||
@required this.icon,
|
||||
@required this.title,
|
||||
@required this.widget,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.widget,
|
||||
this.isUnread,
|
||||
}) : assert(icon != null),
|
||||
assert(title != null),
|
||||
|
@ -7,18 +7,18 @@ import 'package:flutter/material.dart';
|
||||
///
|
||||
/// @author Pierre Hubert
|
||||
|
||||
Future<User> searchUser(BuildContext context, UsersList users) async {
|
||||
return await showSearch<User>(
|
||||
Future<User?> searchUser(BuildContext context, UsersList users) async {
|
||||
return await showSearch<User?>(
|
||||
context: context, delegate: _SearchDelegate(users));
|
||||
}
|
||||
|
||||
class _SearchDelegate extends SearchDelegate<User> {
|
||||
class _SearchDelegate extends SearchDelegate<User?> {
|
||||
final UsersList _usersList;
|
||||
|
||||
_SearchDelegate(this._usersList) : assert(_usersList != null);
|
||||
|
||||
@override
|
||||
List<Widget> buildActions(BuildContext context) => null;
|
||||
List<Widget>? buildActions(BuildContext context) => null;
|
||||
|
||||
@override
|
||||
Widget buildLeading(BuildContext context) => IconButton(
|
||||
@ -28,7 +28,7 @@ class _SearchDelegate extends SearchDelegate<User> {
|
||||
|
||||
@override
|
||||
Widget buildSuggestions(BuildContext context) {
|
||||
final list = _usersList
|
||||
final List<User> list = _usersList
|
||||
.where((element) =>
|
||||
element.fullName.toLowerCase().contains(query.toLowerCase()))
|
||||
.toList();
|
||||
|
Reference in New Issue
Block a user