diff --git a/lib/models/conversation_message.dart b/lib/models/conversation_message.dart index 76e3cc8..4a8cfc4 100644 --- a/lib/models/conversation_message.dart +++ b/lib/models/conversation_message.dart @@ -199,11 +199,8 @@ class ConversationMessage extends SerializableElement { required this.message, required this.file, required this.serverMessage, - }) : assert(id != null), - assert(convID != null), - assert(userID != null || serverMessage != null), - assert(timeSent != null), - assert(message != null || file != null || serverMessage != null); + }) : assert(userID != null || serverMessage != null), + assert(!message.isNull || file != null || serverMessage != null); DateTime get date => DateTime.fromMillisecondsSinceEpoch(timeSent! * 1000); diff --git a/lib/models/count_unread_notifications.dart b/lib/models/count_unread_notifications.dart index a7e7968..1cf9bf3 100644 --- a/lib/models/count_unread_notifications.dart +++ b/lib/models/count_unread_notifications.dart @@ -9,6 +9,5 @@ class CountUnreadNotifications { CountUnreadNotifications({ required int this.notifications, required int this.conversations, - }) : assert(notifications != null), - assert(conversations != null); + }); } diff --git a/lib/ui/widgets/group_membership_widget.dart b/lib/ui/widgets/group_membership_widget.dart index 58c8ad6..b72fe40 100644 --- a/lib/ui/widgets/group_membership_widget.dart +++ b/lib/ui/widgets/group_membership_widget.dart @@ -16,8 +16,7 @@ class GroupMembershipWidget extends StatefulWidget { final Function()? onError; const GroupMembershipWidget( - {required this.group, this.onUpdated, this.onError}) - : assert(group != null); + {required this.group, this.onUpdated, this.onError}); @override _GroupMembershipWidgetState createState() => _GroupMembershipWidgetState(); @@ -120,7 +119,8 @@ class _GroupMembershipWidgetState extends SafeState { /// Cancel group membership request void _cancelRequest() async { 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!(); } else { // Refresh state diff --git a/lib/ui/widgets/icon_button_badge.dart b/lib/ui/widgets/icon_button_badge.dart index 76888d8..fe336e6 100644 --- a/lib/ui/widgets/icon_button_badge.dart +++ b/lib/ui/widgets/icon_button_badge.dart @@ -18,10 +18,7 @@ class IconButtonWithBadge extends StatelessWidget { required this.onPressed, this.number = 0, this.active = false, - }) : assert(icon != null), - assert(number != null), - assert(active != null), - super(key: key); + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/ui/widgets/mobile_mode/mobile_appbar_widget.dart b/lib/ui/widgets/mobile_mode/mobile_appbar_widget.dart index ae8566f..4940b73 100644 --- a/lib/ui/widgets/mobile_mode/mobile_appbar_widget.dart +++ b/lib/ui/widgets/mobile_mode/mobile_appbar_widget.dart @@ -45,10 +45,7 @@ class _MenuItem { required this.action, required this.pageType, this.isMenu = false, - }) : assert(label != null), - assert(isMenu != null), - assert(isMenu || icon != null), - assert(isMenu || action != null), + }) : assert(isMenu || action != null), assert(isMenu || pageType != null); } @@ -57,9 +54,7 @@ class _ActionMenuItem { final String label; final BarCallbackActions action; - const _ActionMenuItem({required this.label, required this.action}) - : assert(label != null), - assert(action != null); + const _ActionMenuItem({required this.label, required this.action}); } /// List of menu items to show @@ -113,8 +108,7 @@ class ComunicMobileAppBar extends StatefulWidget const ComunicMobileAppBar({ Key? key, required this.currentPage, - }) : assert(currentPage != null), - super(key: key); + }) : super(key: key); @override _ComunicMobileAppBarState createState() => _ComunicMobileAppBarState(); @@ -154,8 +148,6 @@ class _ComunicMobileAppBarState extends SafeState { /// Get the number of unread notifications for the selected notice int? getNumberUnread(BarCallbackActions? action) { - if (_unreadNotifications == null) return 0; - switch (action) { case BarCallbackActions.OPEN_NOTIFICATIONS: return _unreadNotifications.notifications; diff --git a/lib/ui/widgets/mobile_mode/user_page_mobile.dart b/lib/ui/widgets/mobile_mode/user_page_mobile.dart index 0586c5a..e1a478c 100644 --- a/lib/ui/widgets/mobile_mode/user_page_mobile.dart +++ b/lib/ui/widgets/mobile_mode/user_page_mobile.dart @@ -19,9 +19,7 @@ class UserMobilePage extends StatefulWidget { Key? key, required this.userInfo, required this.onNeedRefresh, - }) : assert(userInfo != null), - assert(onNeedRefresh != null), - super(key: key); + }) : super(key: key); @override _UserMobilePageState createState() => _UserMobilePageState(); @@ -114,9 +112,7 @@ class UserPageTab { required this.label, required this.onBuild, this.visible = true, - }) : assert(label != null), - assert(onBuild != null), - assert(visible != null); + }); Tab get tab => Tab(text: label); } diff --git a/lib/ui/widgets/network_image_widget.dart b/lib/ui/widgets/network_image_widget.dart index f35d070..b240c28 100644 --- a/lib/ui/widgets/network_image_widget.dart +++ b/lib/ui/widgets/network_image_widget.dart @@ -26,9 +26,7 @@ class NetworkImageWidget extends StatelessWidget { this.height, this.roundedEdges = true, this.loadingHeight, - }) : assert(url != null), - assert(allowFullScreen != null), - super(key: key); + }) : super(key: key); double? get _loadingHeight => loadingHeight != null ? loadingHeight : height; diff --git a/lib/ui/widgets/new_password_input_widget.dart b/lib/ui/widgets/new_password_input_widget.dart index 5ea8e0c..e7569c9 100644 --- a/lib/ui/widgets/new_password_input_widget.dart +++ b/lib/ui/widgets/new_password_input_widget.dart @@ -36,9 +36,7 @@ class NewPasswordInputWidget extends StatefulWidget { this.textInputAction, required this.label, required this.user, - }) : assert(label != null), - assert(user != null), - super(key: key); + }) : super(key: key); @override NewPasswordInputWidgetState createState() => NewPasswordInputWidgetState(); diff --git a/lib/ui/widgets/pick_user_widget.dart b/lib/ui/widgets/pick_user_widget.dart index 786b981..c7ae9ca 100644 --- a/lib/ui/widgets/pick_user_widget.dart +++ b/lib/ui/widgets/pick_user_widget.dart @@ -29,11 +29,7 @@ class PickUserWidget extends StatefulWidget { this.keepFocusOnChoose = false, this.onValueChange, this.enabled = true, - }) : assert(onSelectUser != null), - assert(label != null), - assert(resetOnChoose != null), - assert(keepFocusOnChoose != null), - super(key: key); + }) : super(key: key); @override State createState() => _PickUserWidgetState(); diff --git a/lib/ui/widgets/post_create_form_widget.dart b/lib/ui/widgets/post_create_form_widget.dart index d76b000..ae418e3 100644 --- a/lib/ui/widgets/post_create_form_widget.dart +++ b/lib/ui/widgets/post_create_form_widget.dart @@ -35,9 +35,7 @@ class PostCreateFormWidget extends StatefulWidget { required this.postTarget, required this.targetID, required this.onCreated, - }) : assert(postTarget != null), - assert(targetID != null), - super(key: key); + }) : super(key: key); @override _PostCreateFormWidgetState createState() => _PostCreateFormWidgetState(); @@ -403,10 +401,7 @@ class _PostOptionWidget extends StatelessWidget { required this.selected, required this.onTap, this.customColor}) - : assert(icon != null), - assert(selected != null), - assert(onTap != null), - super(key: key); + : super(key: key); bool get hasCustomColor => customColor != null; diff --git a/lib/ui/widgets/settings/text_settings_edit_tile.dart b/lib/ui/widgets/settings/text_settings_edit_tile.dart index a4c5486..33ef821 100644 --- a/lib/ui/widgets/settings/text_settings_edit_tile.dart +++ b/lib/ui/widgets/settings/text_settings_edit_tile.dart @@ -14,7 +14,7 @@ bool _defaultCheck(String s) => s.isNotEmpty; class TextEditSettingsTile extends SettingsTile { final String title; final String currValue; - final void Function(String) onChanged; + final void Function(String)? onChanged; final bool Function(String) checkInput; final bool allowEmptyValues; final int maxLines; @@ -31,11 +31,7 @@ class TextEditSettingsTile extends SettingsTile { this.allowEmptyValues = false, this.maxLength, this.maxLines = 1, - }) : assert(title != null), - assert(currValue != null), - assert(checkInput != null), - assert(allowEmptyValues != null), - assert(maxLines != null); + }); @override Widget build(BuildContext context) { @@ -64,6 +60,6 @@ class TextEditSettingsTile extends SettingsTile { if (value == null) return; - onChanged(value); + onChanged!(value); } } diff --git a/lib/ui/widgets/survey_widget.dart b/lib/ui/widgets/survey_widget.dart index ba1cb7a..8293126 100644 --- a/lib/ui/widgets/survey_widget.dart +++ b/lib/ui/widgets/survey_widget.dart @@ -19,9 +19,7 @@ class SurveyWidget extends StatefulWidget { Key? key, required this.survey, required this.onUpdated, - }) : assert(survey != null), - assert(onUpdated != null), - super(key: key); + }) : super(key: key); @override _SurveyWidgetState createState() => _SurveyWidgetState(); @@ -202,7 +200,8 @@ class _SurveyWidgetState extends SafeState { try { if (!await showConfirmDialog( 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); diff --git a/lib/ui/widgets/tab_transition_widget.dart b/lib/ui/widgets/tab_transition_widget.dart index 14e95b6..90c2440 100644 --- a/lib/ui/widgets/tab_transition_widget.dart +++ b/lib/ui/widgets/tab_transition_widget.dart @@ -4,8 +4,7 @@ class TabTransitionWidget extends StatefulWidget { final Widget child; const TabTransitionWidget(this.child, {Key? key}) - : assert(child != null), - super(key: key); + : super(key: key); @override _TabTransitionWidgetState createState() => _TabTransitionWidgetState(); diff --git a/lib/ui/widgets/tablet_mode/appbar_custom_dropdown_widget.dart b/lib/ui/widgets/tablet_mode/appbar_custom_dropdown_widget.dart index 7b086df..b902dce 100644 --- a/lib/ui/widgets/tablet_mode/appbar_custom_dropdown_widget.dart +++ b/lib/ui/widgets/tablet_mode/appbar_custom_dropdown_widget.dart @@ -18,10 +18,7 @@ class AppBarCustomDropDownWidget extends StatefulWidget { required this.icon, required this.notificationsBadge, required this.onBuildOverlay, - }) : assert(icon != null), - assert(notificationsBadge != null), - assert(onBuildOverlay != null), - super(key: key); + }) : super(key: key); @override AppBarCustomDropDownWidgetState createState() => diff --git a/lib/ui/widgets/tablet_mode/calls/call_window_widget.dart b/lib/ui/widgets/tablet_mode/calls/call_window_widget.dart index a2e1531..a2ea4ec 100644 --- a/lib/ui/widgets/tablet_mode/calls/call_window_widget.dart +++ b/lib/ui/widgets/tablet_mode/calls/call_window_widget.dart @@ -18,9 +18,7 @@ class CallWindowWidget extends StatefulWidget { Key? key, required this.convID, required this.onClose, - }) : assert(convID != null), - assert(onClose != null), - super(key: key); + }) : super(key: key); @override _CallWindowWidgetState createState() => _CallWindowWidgetState(); diff --git a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart index ec0a48a..94e1af3 100644 --- a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart @@ -27,9 +27,7 @@ class ConversationWindow extends StatefulWidget { Key? key, required this.convID, required this.onClose, - }) : assert(convID != null), - assert(onClose != null), - super(key: key); + }) : super(key: key); @override _ConversationWindowState createState() => _ConversationWindowState(); @@ -59,10 +57,8 @@ class _ConversationWindowState extends SafeState { final conversation = await ConversationsHelper().getSingle(_convID, force: true); - assert(conversation != null); final name = await ConversationsHelper.getConversationNameAsync(conversation); - assert(name != null); setState(() { _conversation = conversation; diff --git a/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart b/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart index 4e662b7..a2c02ea 100644 --- a/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart @@ -27,12 +27,7 @@ class ConversationWindowContainer extends StatelessWidget { required this.onToggleCollapse, required this.isCollapsed, this.action, - }) : assert(title != null), - assert(onClose != null), - assert(body != null), - assert(onToggleCollapse != null), - assert(isCollapsed != null), - super(key: key); + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/ui/widgets/tablet_mode/global_search_field.dart b/lib/ui/widgets/tablet_mode/global_search_field.dart index 220afe9..7fb86c9 100644 --- a/lib/ui/widgets/tablet_mode/global_search_field.dart +++ b/lib/ui/widgets/tablet_mode/global_search_field.dart @@ -147,8 +147,7 @@ class _SearchResultsWidget extends StatelessWidget { Key? key, required this.results, required this.onTap, - }) : assert(onTap != null), - super(key: key); + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/ui/widgets/tablet_mode/memberships_panel.dart b/lib/ui/widgets/tablet_mode/memberships_panel.dart index 95194a5..617698a 100644 --- a/lib/ui/widgets/tablet_mode/memberships_panel.dart +++ b/lib/ui/widgets/tablet_mode/memberships_panel.dart @@ -31,8 +31,7 @@ class MembershipsPanel extends StatefulWidget { const MembershipsPanel({ Key? key, required this.currentPage, - }) : assert(currentPage != null), - super(key: key); + }) : super(key: key); @override _MembershipsPanelState createState() => _MembershipsPanelState(); diff --git a/lib/ui/widgets/tablet_mode/tablet_appbar_widget.dart b/lib/ui/widgets/tablet_mode/tablet_appbar_widget.dart index a689352..389329e 100644 --- a/lib/ui/widgets/tablet_mode/tablet_appbar_widget.dart +++ b/lib/ui/widgets/tablet_mode/tablet_appbar_widget.dart @@ -139,9 +139,7 @@ class _MainMenuItem extends PopupMenuEntry<_MenuItemCallback> { required this.label, required this.icon, required this.onTap, - }) : assert(label != null), - assert(icon != null), - assert(onTap != null); + }); @override __MainMenuItemState createState() => __MainMenuItemState(); diff --git a/lib/ui/widgets/tablet_mode/user_page_tablet.dart b/lib/ui/widgets/tablet_mode/user_page_tablet.dart index cdcc30c..dad5472 100644 --- a/lib/ui/widgets/tablet_mode/user_page_tablet.dart +++ b/lib/ui/widgets/tablet_mode/user_page_tablet.dart @@ -31,9 +31,7 @@ class UserPageTablet extends StatefulWidget { required this.userInfo, required this.friendshipStatus, required this.onNeedRefresh, - }) : assert(userInfo != null), - assert(onNeedRefresh != null), - super(key: key); + }) : super(key: key); @override _UserPageTabletState createState() => _UserPageTabletState(); diff --git a/lib/ui/widgets/text_widget.dart b/lib/ui/widgets/text_widget.dart index f489eeb..e2d7d05 100644 --- a/lib/ui/widgets/text_widget.dart +++ b/lib/ui/widgets/text_widget.dart @@ -24,10 +24,7 @@ class TextWidget extends StatelessWidget { this.textAlign = TextAlign.start, this.style, this.linksColor = Colors.blueAccent, - }) : assert(content != null), - assert(parseBBcode != null), - assert(linksColor != null), - super(key: key); + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/ui/widgets/tour/tour_notifications_pane.dart b/lib/ui/widgets/tour/tour_notifications_pane.dart index 0bf63ec..615cb86 100644 --- a/lib/ui/widgets/tour/tour_notifications_pane.dart +++ b/lib/ui/widgets/tour/tour_notifications_pane.dart @@ -18,8 +18,7 @@ class TourNotificationsPane extends PresentationPane { required Function() onConfigured, required Function() onChanged, required bool visible, - }) : assert(pushNotificationsKey != null), - super( + }) : super( icon: Icons.notifications, title: tr("Push notifications")!, child: (c) => PushNotificationsConfigurationWidget( diff --git a/lib/utils/bbcode_parser.dart b/lib/utils/bbcode_parser.dart index 1567ff1..2b4372e 100644 --- a/lib/utils/bbcode_parser.dart +++ b/lib/utils/bbcode_parser.dart @@ -13,8 +13,7 @@ class BBCodeParsedWidget extends StatelessWidget { final ParseCallBack? parseCallback; BBCodeParsedWidget({required String text, this.parseCallback}) - : assert(text != null), - _content = _parse(text); + : _content = _parse(text); _printRecur(_Element el, {int pos = 0}) { String str; @@ -239,7 +238,7 @@ class _Element { if (parseCallback != null && text != null) { final parsed = parseCallback(generatedStyle, text); - if (parsed != null && parsed.length > 0) + if (parsed.length > 0) return TextSpan( style: generatedStyle, children: parsed, diff --git a/lib/utils/navigation_utils.dart b/lib/utils/navigation_utils.dart index 2babc41..e05563d 100644 --- a/lib/utils/navigation_utils.dart +++ b/lib/utils/navigation_utils.dart @@ -16,9 +16,6 @@ void popPage(BuildContext context) { /// Open the page of a user void openUserPage({required int userID, required BuildContext context}) { - assert(userID != null); - assert(context != null); - MainController.of(context)!.openUserPage(userID); } diff --git a/lib/utils/ui_utils.dart b/lib/utils/ui_utils.dart index 1f081bd..9392a94 100644 --- a/lib/utils/ui_utils.dart +++ b/lib/utils/ui_utils.dart @@ -101,13 +101,6 @@ Future askUserString({ int maxLength = 200, int minLength = 1, }) async { - assert(context != null); - assert(title != null); - assert(message != null); - assert(defaultValue != null); - assert(hint != null); - assert(maxLength != null); - TextEditingController controller = TextEditingController(text: defaultValue); final confirm = await showDialog( @@ -257,7 +250,8 @@ const darkAccentColor = Colors.white70; const darkerAccentColor = Colors.white30; /// 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 bool isTablet(BuildContext context) =>