1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-21 20:39:22 +00:00

Fix a few notices

This commit is contained in:
Pierre HUBERT 2022-03-11 16:36:42 +01:00
parent 06312512a6
commit 45e8f34c81
26 changed files with 38 additions and 110 deletions

View File

@ -199,11 +199,8 @@ class ConversationMessage extends SerializableElement<ConversationMessage> {
required this.message, required this.message,
required this.file, required this.file,
required this.serverMessage, required this.serverMessage,
}) : assert(id != null), }) : assert(userID != null || serverMessage != null),
assert(convID != null), assert(!message.isNull || file != null || serverMessage != null);
assert(userID != null || serverMessage != null),
assert(timeSent != null),
assert(message != null || file != null || serverMessage != null);
DateTime get date => DateTime.fromMillisecondsSinceEpoch(timeSent! * 1000); DateTime get date => DateTime.fromMillisecondsSinceEpoch(timeSent! * 1000);

View File

@ -9,6 +9,5 @@ class CountUnreadNotifications {
CountUnreadNotifications({ CountUnreadNotifications({
required int this.notifications, required int this.notifications,
required int this.conversations, required int this.conversations,
}) : assert(notifications != null), });
assert(conversations != null);
} }

View File

@ -16,8 +16,7 @@ class GroupMembershipWidget extends StatefulWidget {
final Function()? onError; final Function()? onError;
const GroupMembershipWidget( const GroupMembershipWidget(
{required this.group, this.onUpdated, this.onError}) {required this.group, this.onUpdated, this.onError});
: assert(group != null);
@override @override
_GroupMembershipWidgetState createState() => _GroupMembershipWidgetState(); _GroupMembershipWidgetState createState() => _GroupMembershipWidgetState();
@ -120,7 +119,8 @@ class _GroupMembershipWidgetState extends SafeState<GroupMembershipWidget> {
/// Cancel group membership request /// Cancel group membership request
void _cancelRequest() async { void _cancelRequest() async {
if (!await GroupsHelper().cancelRequest(_id)) { if (!await GroupsHelper().cancelRequest(_id)) {
showSimpleSnack(context, tr("Could not cancel your membership request!")!); showSimpleSnack(
context, tr("Could not cancel your membership request!")!);
if (this.widget.onError != null) this.widget.onError!(); if (this.widget.onError != null) this.widget.onError!();
} else { } else {
// Refresh state // Refresh state

View File

@ -18,10 +18,7 @@ class IconButtonWithBadge extends StatelessWidget {
required this.onPressed, required this.onPressed,
this.number = 0, this.number = 0,
this.active = false, this.active = false,
}) : assert(icon != null), }) : super(key: key);
assert(number != null),
assert(active != null),
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -45,10 +45,7 @@ class _MenuItem {
required this.action, required this.action,
required this.pageType, required this.pageType,
this.isMenu = false, this.isMenu = false,
}) : assert(label != null), }) : assert(isMenu || action != null),
assert(isMenu != null),
assert(isMenu || icon != null),
assert(isMenu || action != null),
assert(isMenu || pageType != null); assert(isMenu || pageType != null);
} }
@ -57,9 +54,7 @@ class _ActionMenuItem {
final String label; final String label;
final BarCallbackActions action; 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);
} }
/// List of menu items to show /// List of menu items to show
@ -113,8 +108,7 @@ class ComunicMobileAppBar extends StatefulWidget
const ComunicMobileAppBar({ const ComunicMobileAppBar({
Key? key, Key? key,
required this.currentPage, required this.currentPage,
}) : assert(currentPage != null), }) : super(key: key);
super(key: key);
@override @override
_ComunicMobileAppBarState createState() => _ComunicMobileAppBarState(); _ComunicMobileAppBarState createState() => _ComunicMobileAppBarState();
@ -154,8 +148,6 @@ class _ComunicMobileAppBarState extends SafeState<ComunicMobileAppBar> {
/// Get the number of unread notifications for the selected notice /// 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) { switch (action) {
case BarCallbackActions.OPEN_NOTIFICATIONS: case BarCallbackActions.OPEN_NOTIFICATIONS:
return _unreadNotifications.notifications; return _unreadNotifications.notifications;

View File

@ -19,9 +19,7 @@ class UserMobilePage extends StatefulWidget {
Key? key, Key? key,
required this.userInfo, required this.userInfo,
required this.onNeedRefresh, required this.onNeedRefresh,
}) : assert(userInfo != null), }) : super(key: key);
assert(onNeedRefresh != null),
super(key: key);
@override @override
_UserMobilePageState createState() => _UserMobilePageState(); _UserMobilePageState createState() => _UserMobilePageState();
@ -114,9 +112,7 @@ class UserPageTab {
required this.label, required this.label,
required this.onBuild, required this.onBuild,
this.visible = true, this.visible = true,
}) : assert(label != null), });
assert(onBuild != null),
assert(visible != null);
Tab get tab => Tab(text: label); Tab get tab => Tab(text: label);
} }

View File

@ -26,9 +26,7 @@ class NetworkImageWidget extends StatelessWidget {
this.height, this.height,
this.roundedEdges = true, this.roundedEdges = true,
this.loadingHeight, this.loadingHeight,
}) : assert(url != null), }) : super(key: key);
assert(allowFullScreen != null),
super(key: key);
double? get _loadingHeight => loadingHeight != null ? loadingHeight : height; double? get _loadingHeight => loadingHeight != null ? loadingHeight : height;

View File

@ -36,9 +36,7 @@ class NewPasswordInputWidget extends StatefulWidget {
this.textInputAction, this.textInputAction,
required this.label, required this.label,
required this.user, required this.user,
}) : assert(label != null), }) : super(key: key);
assert(user != null),
super(key: key);
@override @override
NewPasswordInputWidgetState createState() => NewPasswordInputWidgetState(); NewPasswordInputWidgetState createState() => NewPasswordInputWidgetState();

View File

@ -29,11 +29,7 @@ class PickUserWidget extends StatefulWidget {
this.keepFocusOnChoose = false, this.keepFocusOnChoose = false,
this.onValueChange, this.onValueChange,
this.enabled = true, this.enabled = true,
}) : assert(onSelectUser != null), }) : super(key: key);
assert(label != null),
assert(resetOnChoose != null),
assert(keepFocusOnChoose != null),
super(key: key);
@override @override
State<StatefulWidget> createState() => _PickUserWidgetState(); State<StatefulWidget> createState() => _PickUserWidgetState();

View File

@ -35,9 +35,7 @@ class PostCreateFormWidget extends StatefulWidget {
required this.postTarget, required this.postTarget,
required this.targetID, required this.targetID,
required this.onCreated, required this.onCreated,
}) : assert(postTarget != null), }) : super(key: key);
assert(targetID != null),
super(key: key);
@override @override
_PostCreateFormWidgetState createState() => _PostCreateFormWidgetState(); _PostCreateFormWidgetState createState() => _PostCreateFormWidgetState();
@ -403,10 +401,7 @@ class _PostOptionWidget extends StatelessWidget {
required this.selected, required this.selected,
required this.onTap, required this.onTap,
this.customColor}) this.customColor})
: assert(icon != null), : super(key: key);
assert(selected != null),
assert(onTap != null),
super(key: key);
bool get hasCustomColor => customColor != null; bool get hasCustomColor => customColor != null;

View File

@ -14,7 +14,7 @@ bool _defaultCheck(String s) => s.isNotEmpty;
class TextEditSettingsTile extends SettingsTile { class TextEditSettingsTile extends SettingsTile {
final String title; final String title;
final String currValue; final String currValue;
final void Function(String) onChanged; final void Function(String)? onChanged;
final bool Function(String) checkInput; final bool Function(String) checkInput;
final bool allowEmptyValues; final bool allowEmptyValues;
final int maxLines; final int maxLines;
@ -31,11 +31,7 @@ class TextEditSettingsTile extends SettingsTile {
this.allowEmptyValues = false, this.allowEmptyValues = false,
this.maxLength, this.maxLength,
this.maxLines = 1, this.maxLines = 1,
}) : assert(title != null), });
assert(currValue != null),
assert(checkInput != null),
assert(allowEmptyValues != null),
assert(maxLines != null);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -64,6 +60,6 @@ class TextEditSettingsTile extends SettingsTile {
if (value == null) return; if (value == null) return;
onChanged(value); onChanged!(value);
} }
} }

View File

@ -19,9 +19,7 @@ class SurveyWidget extends StatefulWidget {
Key? key, Key? key,
required this.survey, required this.survey,
required this.onUpdated, required this.onUpdated,
}) : assert(survey != null), }) : super(key: key);
assert(onUpdated != null),
super(key: key);
@override @override
_SurveyWidgetState createState() => _SurveyWidgetState(); _SurveyWidgetState createState() => _SurveyWidgetState();
@ -202,7 +200,8 @@ class _SurveyWidgetState extends SafeState<SurveyWidget> {
try { try {
if (!await showConfirmDialog( if (!await showConfirmDialog(
context: context, context: context,
message: tr("Do you really want to block new choices creation?"))) return; message: tr("Do you really want to block new choices creation?")))
return;
await SurveyHelper.blockNewChoicesCreation(survey.postID); await SurveyHelper.blockNewChoicesCreation(survey.postID);

View File

@ -4,8 +4,7 @@ class TabTransitionWidget extends StatefulWidget {
final Widget child; final Widget child;
const TabTransitionWidget(this.child, {Key? key}) const TabTransitionWidget(this.child, {Key? key})
: assert(child != null), : super(key: key);
super(key: key);
@override @override
_TabTransitionWidgetState createState() => _TabTransitionWidgetState(); _TabTransitionWidgetState createState() => _TabTransitionWidgetState();

View File

@ -18,10 +18,7 @@ class AppBarCustomDropDownWidget extends StatefulWidget {
required this.icon, required this.icon,
required this.notificationsBadge, required this.notificationsBadge,
required this.onBuildOverlay, required this.onBuildOverlay,
}) : assert(icon != null), }) : super(key: key);
assert(notificationsBadge != null),
assert(onBuildOverlay != null),
super(key: key);
@override @override
AppBarCustomDropDownWidgetState createState() => AppBarCustomDropDownWidgetState createState() =>

View File

@ -18,9 +18,7 @@ class CallWindowWidget extends StatefulWidget {
Key? key, Key? key,
required this.convID, required this.convID,
required this.onClose, required this.onClose,
}) : assert(convID != null), }) : super(key: key);
assert(onClose != null),
super(key: key);
@override @override
_CallWindowWidgetState createState() => _CallWindowWidgetState(); _CallWindowWidgetState createState() => _CallWindowWidgetState();

View File

@ -27,9 +27,7 @@ class ConversationWindow extends StatefulWidget {
Key? key, Key? key,
required this.convID, required this.convID,
required this.onClose, required this.onClose,
}) : assert(convID != null), }) : super(key: key);
assert(onClose != null),
super(key: key);
@override @override
_ConversationWindowState createState() => _ConversationWindowState(); _ConversationWindowState createState() => _ConversationWindowState();
@ -59,10 +57,8 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
final conversation = final conversation =
await ConversationsHelper().getSingle(_convID, force: true); await ConversationsHelper().getSingle(_convID, force: true);
assert(conversation != null);
final name = final name =
await ConversationsHelper.getConversationNameAsync(conversation); await ConversationsHelper.getConversationNameAsync(conversation);
assert(name != null);
setState(() { setState(() {
_conversation = conversation; _conversation = conversation;

View File

@ -27,12 +27,7 @@ class ConversationWindowContainer extends StatelessWidget {
required this.onToggleCollapse, required this.onToggleCollapse,
required this.isCollapsed, required this.isCollapsed,
this.action, this.action,
}) : assert(title != null), }) : super(key: key);
assert(onClose != null),
assert(body != null),
assert(onToggleCollapse != null),
assert(isCollapsed != null),
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -147,8 +147,7 @@ class _SearchResultsWidget extends StatelessWidget {
Key? key, Key? key,
required this.results, required this.results,
required this.onTap, required this.onTap,
}) : assert(onTap != null), }) : super(key: key);
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -31,8 +31,7 @@ class MembershipsPanel extends StatefulWidget {
const MembershipsPanel({ const MembershipsPanel({
Key? key, Key? key,
required this.currentPage, required this.currentPage,
}) : assert(currentPage != null), }) : super(key: key);
super(key: key);
@override @override
_MembershipsPanelState createState() => _MembershipsPanelState(); _MembershipsPanelState createState() => _MembershipsPanelState();

View File

@ -139,9 +139,7 @@ class _MainMenuItem extends PopupMenuEntry<_MenuItemCallback> {
required this.label, required this.label,
required this.icon, required this.icon,
required this.onTap, required this.onTap,
}) : assert(label != null), });
assert(icon != null),
assert(onTap != null);
@override @override
__MainMenuItemState createState() => __MainMenuItemState(); __MainMenuItemState createState() => __MainMenuItemState();

View File

@ -31,9 +31,7 @@ class UserPageTablet extends StatefulWidget {
required this.userInfo, required this.userInfo,
required this.friendshipStatus, required this.friendshipStatus,
required this.onNeedRefresh, required this.onNeedRefresh,
}) : assert(userInfo != null), }) : super(key: key);
assert(onNeedRefresh != null),
super(key: key);
@override @override
_UserPageTabletState createState() => _UserPageTabletState(); _UserPageTabletState createState() => _UserPageTabletState();

View File

@ -24,10 +24,7 @@ class TextWidget extends StatelessWidget {
this.textAlign = TextAlign.start, this.textAlign = TextAlign.start,
this.style, this.style,
this.linksColor = Colors.blueAccent, this.linksColor = Colors.blueAccent,
}) : assert(content != null), }) : super(key: key);
assert(parseBBcode != null),
assert(linksColor != null),
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -18,8 +18,7 @@ class TourNotificationsPane extends PresentationPane {
required Function() onConfigured, required Function() onConfigured,
required Function() onChanged, required Function() onChanged,
required bool visible, required bool visible,
}) : assert(pushNotificationsKey != null), }) : super(
super(
icon: Icons.notifications, icon: Icons.notifications,
title: tr("Push notifications")!, title: tr("Push notifications")!,
child: (c) => PushNotificationsConfigurationWidget( child: (c) => PushNotificationsConfigurationWidget(

View File

@ -13,8 +13,7 @@ class BBCodeParsedWidget extends StatelessWidget {
final ParseCallBack? parseCallback; final ParseCallBack? parseCallback;
BBCodeParsedWidget({required String text, this.parseCallback}) BBCodeParsedWidget({required String text, this.parseCallback})
: assert(text != null), : _content = _parse(text);
_content = _parse(text);
_printRecur(_Element el, {int pos = 0}) { _printRecur(_Element el, {int pos = 0}) {
String str; String str;
@ -239,7 +238,7 @@ class _Element {
if (parseCallback != null && text != null) { if (parseCallback != null && text != null) {
final parsed = parseCallback(generatedStyle, text); final parsed = parseCallback(generatedStyle, text);
if (parsed != null && parsed.length > 0) if (parsed.length > 0)
return TextSpan( return TextSpan(
style: generatedStyle, style: generatedStyle,
children: parsed, children: parsed,

View File

@ -16,9 +16,6 @@ void popPage(BuildContext context) {
/// Open the page of a user /// Open the page of a user
void openUserPage({required int userID, required BuildContext context}) { void openUserPage({required int userID, required BuildContext context}) {
assert(userID != null);
assert(context != null);
MainController.of(context)!.openUserPage(userID); MainController.of(context)!.openUserPage(userID);
} }

View File

@ -101,13 +101,6 @@ Future<String?> askUserString({
int maxLength = 200, int maxLength = 200,
int minLength = 1, int minLength = 1,
}) async { }) async {
assert(context != null);
assert(title != null);
assert(message != null);
assert(defaultValue != null);
assert(hint != null);
assert(maxLength != null);
TextEditingController controller = TextEditingController(text: defaultValue); TextEditingController controller = TextEditingController(text: defaultValue);
final confirm = await showDialog<bool>( final confirm = await showDialog<bool>(
@ -257,7 +250,8 @@ const darkAccentColor = Colors.white70;
const darkerAccentColor = Colors.white30; const darkerAccentColor = Colors.white30;
/// Check out whether dark theme is enabled or not /// Check out whether dark theme is enabled or not
bool darkTheme() => preferences()!.getBool(PreferencesKeyList.ENABLE_DARK_THEME); bool darkTheme() =>
preferences()!.getBool(PreferencesKeyList.ENABLE_DARK_THEME);
/// Check out whether we use tablet mode or not /// Check out whether we use tablet mode or not
bool isTablet(BuildContext context) => bool isTablet(BuildContext context) =>