From 41446f0e5bc984552f6cd355c88844f2c77161f4 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 11 Mar 2022 17:09:37 +0100 Subject: [PATCH] Fix a few notices --- lib/models/post.dart | 15 ++---- .../res_check_password_reset_token.dart | 6 +-- lib/models/search_result.dart | 5 +- lib/models/security_settings.dart | 7 +-- lib/models/server_config.dart | 52 +++---------------- lib/models/survey_choice.dart | 6 +-- lib/models/unread_conversation.dart | 3 +- lib/models/ws_message.dart | 9 ++-- lib/ui/dialogs/alert_dialog.dart | 4 +- lib/ui/dialogs/audio_player_dialog.dart | 3 +- lib/ui/dialogs/input_new_password_dialog.dart | 8 ++- lib/ui/dialogs/multi_choices_dialog.dart | 4 +- lib/ui/dialogs/pick_file_dialog.dart | 11 +--- lib/ui/dialogs/record_audio_dialog.dart | 8 +-- lib/ui/dialogs/single_input_dialog.dart | 7 +-- lib/ui/dialogs/virtual_directory_dialog.dart | 10 +--- lib/ui/routes/forgot_password_route.dart | 4 +- lib/ui/routes/main_route/main_route.dart | 3 +- lib/ui/routes/push_notifications_route.dart | 2 +- .../custom_emojies_account_settings.dart | 3 +- lib/ui/screens/group_settings_screen.dart | 3 +- lib/ui/tiles/menu_tile.dart | 2 +- 22 files changed, 36 insertions(+), 139 deletions(-) diff --git a/lib/models/post.dart b/lib/models/post.dart index fc7cfe8..19dde81 100644 --- a/lib/models/post.dart +++ b/lib/models/post.dart @@ -58,22 +58,13 @@ class Post implements LikeElement { required this.access, required this.comments, required this.survey}) - : assert(id != null), - assert(userID != null), - assert(userPageID != 0 || groupID != 0), - assert(timeSent != null), - assert(kind != PostKind.TEXT || content != null), - assert(visibilityLevel != null), - assert(kind != null), + : assert(userPageID != 0 || groupID != 0), assert(kind != PostKind.COUNTDOWN || timeEnd != null), - assert(kind != PostKind.SURVEY || survey != null), - assert(likes != null), - assert(userLike != null), - assert(access != null); + assert(kind != PostKind.SURVEY || survey != null); bool get isGroupPost => groupID != null && groupID! > 0; - bool get hasContent => content != null && !content.isNull; + bool get hasContent => !content.isNull && !content.isEmpty; bool get hasComments => comments != null; diff --git a/lib/models/res_check_password_reset_token.dart b/lib/models/res_check_password_reset_token.dart index aa57b2d..cb67fd5 100644 --- a/lib/models/res_check_password_reset_token.dart +++ b/lib/models/res_check_password_reset_token.dart @@ -1,5 +1,3 @@ - - /// Check password reset token result /// /// @author Pierre Hubert @@ -13,7 +11,5 @@ class ResCheckPasswordToken { required this.firstName, required this.lastName, required this.email, - }) : assert(firstName != null), - assert(lastName != null), - assert(email != null); + }); } diff --git a/lib/models/search_result.dart b/lib/models/search_result.dart index 54db2fa..4bff880 100644 --- a/lib/models/search_result.dart +++ b/lib/models/search_result.dart @@ -1,5 +1,3 @@ - - /// Single search result /// /// @author Pierre Hubert @@ -13,6 +11,5 @@ class SearchResult { SearchResult({ required this.id, required this.kind, - }) : assert(id != null), - assert(kind != null); + }); } diff --git a/lib/models/security_settings.dart b/lib/models/security_settings.dart index dfe9599..5684755 100644 --- a/lib/models/security_settings.dart +++ b/lib/models/security_settings.dart @@ -1,5 +1,3 @@ - - /// Security settings of the user /// /// @author Pierre HUBERT @@ -15,8 +13,5 @@ class SecuritySettings { required this.securityAnswer1, required this.securityQuestion2, required this.securityAnswer2, - }) : assert(securityQuestion1 != null), - assert(securityAnswer1 != null), - assert(securityQuestion2 != null), - assert(securityAnswer2 != null); + }); } diff --git a/lib/models/server_config.dart b/lib/models/server_config.dart index c3128ba..3cc1445 100644 --- a/lib/models/server_config.dart +++ b/lib/models/server_config.dart @@ -35,14 +35,7 @@ class PasswordPolicy { required this.minNumberDigits, required this.minNumberSpecialCharacters, required this.minCategoriesPresence, - }) : assert(allowMailInPassword != null), - assert(allowNameInPassword != null), - assert(minPasswordLength != null), - assert(minNumberUpperCaseLetters != null), - assert(minNumberLowerCaseLetters != null), - assert(minNumberDigits != null), - assert(minNumberSpecialCharacters != null), - assert(minCategoriesPresence != null); + }); } class ServerDataConservationPolicy { @@ -60,12 +53,7 @@ class ServerDataConservationPolicy { required this.minPostsLifetime, required this.minConversationMessagesLifetime, required this.minLikesLifetime, - }) : assert(minInactiveAccountLifetime != null), - assert(minNotificationLifetime != null), - assert(minCommentsLifetime != null), - assert(minPostsLifetime != null), - assert(minConversationMessagesLifetime != null), - assert(minLikesLifetime != null); + }); } class ConversationsPolicy { @@ -97,19 +85,7 @@ class ConversationsPolicy { required this.maxThumbnailHeight, required this.maxLogoWidth, required this.maxLogoHeight, - }) : assert(maxConversationNameLen != null), - assert(minMessageLen != null), - assert(maxMessageLen != null), - assert(allowedFilesType != null), - assert(filesMaxSize != null), - assert(writingEventInterval != null), - assert(writingEventLifetime != null), - assert(maxMessageImageWidth != null), - assert(maxMessageImageHeight != null), - assert(maxThumbnailWidth != null), - assert(maxThumbnailHeight != null), - assert(maxLogoWidth != null), - assert(maxLogoHeight != null); + }); } class AccountInformationPolicy { @@ -125,11 +101,7 @@ class AccountInformationPolicy { required this.minLastNameLength, required this.maxLastNameLength, required this.maxLocationLength, - }) : assert(minFirstNameLength != null), - assert(maxFirstNameLength != null), - assert(minLastNameLength != null), - assert(maxLastNameLength != null), - assert(maxLocationLength != null); + }); } enum BannerNature { Information, Warning, Success } @@ -161,9 +133,7 @@ class Banner { required this.nature, required this.message, required this.link, - }) : assert(enabled != null), - assert(nature != null), - assert(message != null); + }); bool get visible => enabled && (expire == null || expire! > time()); } @@ -195,15 +165,5 @@ class ServerConfig { required this.dataConservationPolicy, required this.conversationsPolicy, required this.accountInformationPolicy, - }) : assert(minSupportedMobileVersion != null), - assert(termsURL != null), - assert(privacyPolicyURL != null), - assert(contactEmail != null), - assert(playStoreURL != null), - assert(androidDirectDownloadURL != null), - assert(notificationsPolicy != null), - assert(passwordPolicy != null), - assert(dataConservationPolicy != null), - assert(conversationsPolicy != null), - assert(accountInformationPolicy != null); + }); } diff --git a/lib/models/survey_choice.dart b/lib/models/survey_choice.dart index aad40e5..4a6bcfe 100644 --- a/lib/models/survey_choice.dart +++ b/lib/models/survey_choice.dart @@ -1,5 +1,3 @@ - - /// Single survey choice /// /// @author Pierre HUBERT @@ -13,7 +11,5 @@ class SurveyChoice { required this.id, required this.name, required this.responses, - }) : assert(id != null), - assert(name != null), - assert(responses != null); + }); } diff --git a/lib/models/unread_conversation.dart b/lib/models/unread_conversation.dart index ccea0ff..c680688 100644 --- a/lib/models/unread_conversation.dart +++ b/lib/models/unread_conversation.dart @@ -12,6 +12,5 @@ class UnreadConversation { const UnreadConversation({ required this.conv, required this.message, - }) : assert(conv != null), - assert(message != null); + }); } diff --git a/lib/models/ws_message.dart b/lib/models/ws_message.dart index 3cf4d96..81e19eb 100644 --- a/lib/models/ws_message.dart +++ b/lib/models/ws_message.dart @@ -13,9 +13,7 @@ class WsMessage { required this.id, required this.title, required this.data, - }) : assert(id != null), - assert(title != null), - assert(title.length > 0); + }) : assert(title.length > 0); /// Construct a message from a JSON document (messages coming from the server) static WsMessage fromJSON(final Map m) { @@ -23,12 +21,11 @@ class WsMessage { } /// Turn a message into a JSON object to send it to the API - String toJSON() => - jsonEncode({ + String toJSON() => jsonEncode({ "id": id, "title": title, "data": data, }); - bool get hasId => this.id != null && this.id.isNotEmpty; + bool get hasId => this.id.isNotEmpty; } diff --git a/lib/ui/dialogs/alert_dialog.dart b/lib/ui/dialogs/alert_dialog.dart index 6bca726..5d127fa 100644 --- a/lib/ui/dialogs/alert_dialog.dart +++ b/lib/ui/dialogs/alert_dialog.dart @@ -11,9 +11,7 @@ Future alert(BuildContext context, String? msg) async { class _AlertDialog extends StatelessWidget { final String msg; - const _AlertDialog({Key? key, required this.msg}) - : assert(msg != null), - super(key: key); + const _AlertDialog({Key? key, required this.msg}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/ui/dialogs/audio_player_dialog.dart b/lib/ui/dialogs/audio_player_dialog.dart index 972f759..f5e9a05 100644 --- a/lib/ui/dialogs/audio_player_dialog.dart +++ b/lib/ui/dialogs/audio_player_dialog.dart @@ -19,8 +19,7 @@ class _AudioPlayerDialog extends StatefulWidget { const _AudioPlayerDialog({ Key? key, required this.url, - }) : assert(url != null), - super(key: key); + }) : super(key: key); @override __AudioPlayerDialogState createState() => __AudioPlayerDialogState(); diff --git a/lib/ui/dialogs/input_new_password_dialog.dart b/lib/ui/dialogs/input_new_password_dialog.dart index 28cd45f..b5fb4e0 100644 --- a/lib/ui/dialogs/input_new_password_dialog.dart +++ b/lib/ui/dialogs/input_new_password_dialog.dart @@ -12,8 +12,6 @@ Future showInputNewPassword({ required BuildContext context, required UserInfoForPassword userInfo, }) async { - assert(context != null); - assert(userInfo != null); return await showDialog( context: context, builder: (c) => _InputNewPasswordDialog( @@ -27,8 +25,7 @@ class _InputNewPasswordDialog extends StatefulWidget { const _InputNewPasswordDialog({ Key? key, required this.userInfo, - }) : assert(userInfo != null), - super(key: key); + }) : super(key: key); @override __InputNewPasswordDialogState createState() => @@ -45,7 +42,8 @@ class __InputNewPasswordDialogState extends State<_InputNewPasswordDialog> { bool get _input1Valid => _controller1.currentState != null && _controller1.currentState!.valid; - bool get _input2Valid => _controller1.currentState!.value == _controller2.text; + bool get _input2Valid => + _controller1.currentState!.value == _controller2.text; bool get _isValid => _input1Valid && _input2Valid; diff --git a/lib/ui/dialogs/multi_choices_dialog.dart b/lib/ui/dialogs/multi_choices_dialog.dart index a19591d..7088ba7 100644 --- a/lib/ui/dialogs/multi_choices_dialog.dart +++ b/lib/ui/dialogs/multi_choices_dialog.dart @@ -51,9 +51,7 @@ class _MultiChoicesEntryDialog extends StatefulWidget { required this.title, required this.defaultChoice, required this.choices, - }) : assert(title != null), - assert(defaultChoice != null), - assert(choices != null), + }) : assert(defaultChoice != null), super(key: key); @override diff --git a/lib/ui/dialogs/pick_file_dialog.dart b/lib/ui/dialogs/pick_file_dialog.dart index 693fe4c..91774d0 100644 --- a/lib/ui/dialogs/pick_file_dialog.dart +++ b/lib/ui/dialogs/pick_file_dialog.dart @@ -39,10 +39,7 @@ class _PickFileOption { required this.label, required this.icon, required this.canEnable, - }) : assert(value != null), - assert(label != null), - assert(icon != null), - assert(canEnable != null); + }); } List<_PickFileOption> get _optionsList => [ @@ -94,8 +91,6 @@ Future showPickFileDialog({ int? imageMaxHeight, CropAspectRatio? aspectRatio, }) async { - assert(allowedMimeTypes != null); - // Get the list of allowed extension final allowedExtensions = []; for (var mime in allowedExtensions) { @@ -196,9 +191,7 @@ class _BottomSheetPickOption extends StatelessWidget { const _BottomSheetPickOption( {Key? key, required this.options, required this.onOptionSelected}) - : assert(options != null), - assert(onOptionSelected != null), - super(key: key); + : super(key: key); @override Widget build(BuildContext context) => Container( diff --git a/lib/ui/dialogs/record_audio_dialog.dart b/lib/ui/dialogs/record_audio_dialog.dart index bfeb728..eca94c0 100644 --- a/lib/ui/dialogs/record_audio_dialog.dart +++ b/lib/ui/dialogs/record_audio_dialog.dart @@ -266,9 +266,7 @@ class _RecordAction extends StatelessWidget { required this.icon, required this.onTap, this.color, - }) : assert(visible != null), - assert(icon != null), - super(key: key); + }) : super(key: key); @override Widget build(BuildContext context) { @@ -287,9 +285,7 @@ class _ActionButton extends StatelessWidget { required this.visible, required this.text, this.onPressed, - }) : assert(visible != null), - assert(text != null), - super(key: key); + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/ui/dialogs/single_input_dialog.dart b/lib/ui/dialogs/single_input_dialog.dart index eb4378f..5405a9f 100644 --- a/lib/ui/dialogs/single_input_dialog.dart +++ b/lib/ui/dialogs/single_input_dialog.dart @@ -27,12 +27,7 @@ class SingleInputDialog extends StatefulWidget { this.canBeEmpty = false, this.maxLines = 1, this.maxLength, - }) : assert(title != null), - assert(label != null), - assert(checkInput != null), - assert(errorMessage != null), - assert(maxLines != null), - super(key: key); + }) : super(key: key); @override __InputURLDialogState createState() => __InputURLDialogState(); diff --git a/lib/ui/dialogs/virtual_directory_dialog.dart b/lib/ui/dialogs/virtual_directory_dialog.dart index 244bfaf..57dedd5 100644 --- a/lib/ui/dialogs/virtual_directory_dialog.dart +++ b/lib/ui/dialogs/virtual_directory_dialog.dart @@ -18,11 +18,6 @@ Future showVirtualDirectoryDialog({ required int id, required VirtualDirectoryTargetType type, }) async { - assert(context != null); - assert(initialDirectory != null); - assert(id != null); - assert(type != null); - return await showDialog( context: context, builder: (c) => _VirtualDirectoryPicker( @@ -39,10 +34,7 @@ class _VirtualDirectoryPicker extends StatefulWidget { required this.initialDirectory, required this.id, required this.type, - }) : assert(initialDirectory != null), - assert(id != null), - assert(type != null), - super(key: key); + }) : super(key: key); @override __VirtualDirectoryPickerState createState() => diff --git a/lib/ui/routes/forgot_password_route.dart b/lib/ui/routes/forgot_password_route.dart index 579751a..203962e 100644 --- a/lib/ui/routes/forgot_password_route.dart +++ b/lib/ui/routes/forgot_password_route.dart @@ -246,9 +246,7 @@ class _ResetPasswordBodyState extends SafeState<_ResetPasswordBody> { class _Spacer extends StatelessWidget { final bool visible; - const _Spacer({Key? key, this.visible = true}) - : assert(visible != null), - super(key: key); + const _Spacer({Key? key, this.visible = true}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/ui/routes/main_route/main_route.dart b/lib/ui/routes/main_route/main_route.dart index 03348c7..316611c 100644 --- a/lib/ui/routes/main_route/main_route.dart +++ b/lib/ui/routes/main_route/main_route.dart @@ -50,8 +50,9 @@ abstract class MainController extends State { int get numberOfPages => _pagesStack.length; /// Get current instance of Home controller + /// + /// A future implementation might need context again, that is why it is required static MainController? of(BuildContext context) { - assert(context != null); // A future implementation might need context again return mainControllerKey.currentState; } diff --git a/lib/ui/routes/push_notifications_route.dart b/lib/ui/routes/push_notifications_route.dart index 89c988c..ce75d7d 100644 --- a/lib/ui/routes/push_notifications_route.dart +++ b/lib/ui/routes/push_notifications_route.dart @@ -126,7 +126,7 @@ class PushNotificationsConfigurationWidgetState available: srvConfig!.notificationsPolicy.hasFirebase, onChanged: (s) { setState(() => currStatus = s); - if (widget.onChanged != null) widget.onChanged(); + widget.onChanged(); }, ), SizedBox(height: 5), diff --git a/lib/ui/routes/settings/custom_emojies_account_settings.dart b/lib/ui/routes/settings/custom_emojies_account_settings.dart index 837e4f4..e90d25f 100644 --- a/lib/ui/routes/settings/custom_emojies_account_settings.dart +++ b/lib/ui/routes/settings/custom_emojies_account_settings.dart @@ -129,8 +129,7 @@ class _NewCustomEmojiDialog extends StatefulWidget { const _NewCustomEmojiDialog({ Key? key, required this.currentList, - }) : assert(currentList != null), - super(key: key); + }) : super(key: key); @override _NewCustomEmojiDialogState createState() => _NewCustomEmojiDialogState(); diff --git a/lib/ui/screens/group_settings_screen.dart b/lib/ui/screens/group_settings_screen.dart index 70149f8..1840f09 100644 --- a/lib/ui/screens/group_settings_screen.dart +++ b/lib/ui/screens/group_settings_screen.dart @@ -35,8 +35,7 @@ class GroupSettingsScreen extends StatefulWidget { final int groupID; const GroupSettingsScreen({Key? key, required this.groupID}) - : assert(groupID != null), - super(key: key); + : super(key: key); @override _GroupSettingsScreenState createState() => _GroupSettingsScreenState(); diff --git a/lib/ui/tiles/menu_tile.dart b/lib/ui/tiles/menu_tile.dart index 4ff48ba..0c8eaa6 100644 --- a/lib/ui/tiles/menu_tile.dart +++ b/lib/ui/tiles/menu_tile.dart @@ -8,7 +8,7 @@ class MenuTile extends StatelessWidget { final String title; final GestureTapCallback? onTap; - const MenuTile({required this.title, this.onTap}) : assert(title != null); + const MenuTile({required this.title, this.onTap}); @override Widget build(BuildContext context) {