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,9 +24,9 @@ class ConversationWindow extends StatefulWidget {
|
||||
final Function() onClose;
|
||||
|
||||
const ConversationWindow({
|
||||
Key key,
|
||||
@required this.convID,
|
||||
@required this.onClose,
|
||||
Key? key,
|
||||
required this.convID,
|
||||
required this.onClose,
|
||||
}) : assert(convID != null),
|
||||
assert(onClose != null),
|
||||
super(key: key);
|
||||
@ -36,8 +36,8 @@ class ConversationWindow extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
Conversation _conversation;
|
||||
String _convTitle;
|
||||
Conversation? _conversation;
|
||||
late String _convTitle;
|
||||
bool _error = false;
|
||||
bool _collapsed = false;
|
||||
bool _hasNewMessages = false;
|
||||
@ -71,7 +71,7 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
} catch (e, s) {
|
||||
_setError(true);
|
||||
print("Could not refresh the list of conversations! $e\n$s");
|
||||
showSimpleSnack(context, tr("Could not load conversation information!"));
|
||||
showSimpleSnack(context, tr("Could not load conversation information!")!);
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
if (_error)
|
||||
return ConversationWindowContainer(
|
||||
icon: Icon(Icons.error),
|
||||
title: Text(tr("Error")),
|
||||
title: Text(tr("Error")!),
|
||||
onClose: widget.onClose,
|
||||
onToggleCollapse: _toggleVisibility,
|
||||
isCollapsed: _collapsed,
|
||||
@ -100,7 +100,7 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: _refresh,
|
||||
child: Text(tr("Try again").toUpperCase()),
|
||||
child: Text(tr("Try again")!.toUpperCase()),
|
||||
)
|
||||
]),
|
||||
);
|
||||
@ -109,7 +109,7 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
if (_conversation == null)
|
||||
return ConversationWindowContainer(
|
||||
icon: Icon(Icons.message),
|
||||
title: Text(tr("Loading...")),
|
||||
title: Text(tr("Loading...")!),
|
||||
onClose: widget.onClose,
|
||||
onToggleCollapse: _toggleVisibility,
|
||||
isCollapsed: _collapsed,
|
||||
@ -123,7 +123,7 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
onClose: widget.onClose,
|
||||
onToggleCollapse: _toggleVisibility,
|
||||
isCollapsed: _collapsed,
|
||||
action: (_conversation.callCapabilities != CallCapabilities.NONE
|
||||
action: (_conversation!.callCapabilities != CallCapabilities.NONE
|
||||
? [IconButton(icon: Icon(Icons.call), onPressed: _startCall)]
|
||||
: [])
|
||||
..addAll(<Widget>[
|
||||
@ -131,19 +131,19 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
itemBuilder: (c) => [
|
||||
// Show in full screen
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Open in full screen")),
|
||||
child: Text(tr("Open in full screen")!),
|
||||
value: _Actions.OPEN_FULL_SCREEN,
|
||||
),
|
||||
|
||||
// Show the list of members
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Members")),
|
||||
child: Text(tr("Members")!),
|
||||
value: _Actions.OPEN_MEMBERS,
|
||||
),
|
||||
|
||||
// Show conversation settings
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Settings")),
|
||||
child: Text(tr("Settings")!),
|
||||
value: _Actions.OPEN_SETTINGS,
|
||||
)
|
||||
],
|
||||
@ -174,8 +174,8 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
}
|
||||
|
||||
void _openFullScreen() {
|
||||
MainController.of(context)
|
||||
.openConversation(_conversation, fullScreen: true);
|
||||
MainController.of(context)!
|
||||
.openConversation(_conversation!, fullScreen: true);
|
||||
widget.onClose();
|
||||
}
|
||||
|
||||
@ -189,5 +189,5 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
_refresh();
|
||||
}
|
||||
|
||||
void _startCall() => MainController.of(context).startCall(_convID);
|
||||
void _startCall() => MainController.of(context)!.startCall(_convID);
|
||||
}
|
||||
|
@ -8,24 +8,24 @@ import 'package:flutter/material.dart';
|
||||
/// @author Pierre Hubert
|
||||
|
||||
class ConversationWindowContainer extends StatelessWidget {
|
||||
final Color appBarBgColor;
|
||||
final Widget icon;
|
||||
final Color? appBarBgColor;
|
||||
final Widget? icon;
|
||||
final Widget title;
|
||||
final void Function() onClose;
|
||||
final void Function() onToggleCollapse;
|
||||
final bool isCollapsed;
|
||||
final Widget body;
|
||||
final List<Widget> action;
|
||||
final List<Widget>? action;
|
||||
|
||||
const ConversationWindowContainer({
|
||||
Key key,
|
||||
Key? key,
|
||||
this.appBarBgColor,
|
||||
this.icon,
|
||||
@required this.title,
|
||||
@required this.onClose,
|
||||
@required this.body,
|
||||
@required this.onToggleCollapse,
|
||||
@required this.isCollapsed,
|
||||
required this.title,
|
||||
required this.onClose,
|
||||
required this.body,
|
||||
required this.onToggleCollapse,
|
||||
required this.isCollapsed,
|
||||
this.action,
|
||||
}) : assert(title != null),
|
||||
assert(onClose != null),
|
||||
@ -47,7 +47,7 @@ class ConversationWindowContainer extends StatelessWidget {
|
||||
backgroundColor: appBarBgColor,
|
||||
leading: icon,
|
||||
title: GestureDetector(child: title, onTap: onToggleCollapse),
|
||||
actions: (action == null ? [] : action)
|
||||
actions: action ?? []
|
||||
..add(
|
||||
IconButton(icon: Icon(Icons.close), onPressed: onClose),
|
||||
),
|
||||
|
@ -9,14 +9,14 @@ import 'package:flutter/material.dart';
|
||||
/// @author Pierre
|
||||
|
||||
class ConversationsAreaWidget extends StatefulWidget {
|
||||
const ConversationsAreaWidget({Key key}) : super(key: key);
|
||||
const ConversationsAreaWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
ConversationsAreaWidgetState createState() => ConversationsAreaWidgetState();
|
||||
}
|
||||
|
||||
class ConversationsAreaWidgetState extends State<ConversationsAreaWidget> {
|
||||
final _openConversations = Map<int, UniqueKey>();
|
||||
final _openConversations = Map<int?, UniqueKey>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -31,17 +31,17 @@ class ConversationsAreaWidgetState extends State<ConversationsAreaWidget> {
|
||||
Widget _buildOpenButton() => OpenConversationButton();
|
||||
|
||||
/// Open a new conversation
|
||||
void openConversations(int convID) {
|
||||
void openConversations(int? convID) {
|
||||
if (!_openConversations.containsKey(convID))
|
||||
setState(() => _openConversations[convID] = UniqueKey());
|
||||
}
|
||||
|
||||
MapEntry<int, Widget> _conversationWindow(int convID, UniqueKey key) =>
|
||||
MapEntry<int?, Widget> _conversationWindow(int? convID, UniqueKey key) =>
|
||||
MapEntry(
|
||||
convID,
|
||||
ConversationWindow(
|
||||
key: key,
|
||||
convID: convID,
|
||||
convID: convID!,
|
||||
onClose: () => setState(() => _openConversations.remove(convID)),
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user