diff --git a/analysis_options.yaml b/analysis_options.yaml index 09d6844..4beae06 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -112,12 +112,15 @@ linter: - unnecessary_string_interpolations - unnecessary_this - unrelated_type_equality_checks + - use_colored_box + - use_enums - use_full_hex_values_for_flutter_colors - use_is_even_rather_than_modulo - use_named_constants - use_raw_strings - use_rethrow_when_possible - use_setters_to_change_properties + - use_super_parameters - use_test_throws_matchers - use_to_and_as_if_applicable - void_checks diff --git a/lib/comment_tree.dart b/lib/comment_tree.dart index f935dac..6bbbcde 100644 --- a/lib/comment_tree.dart +++ b/lib/comment_tree.dart @@ -7,10 +7,8 @@ enum CommentSortType { top, new_, old, - chat, -} + chat; -extension on CommentSortType { /// returns a compare function for sorting a CommentTree according /// to the comment sort type int Function(CommentTree a, CommentTree b) get sortFunction { diff --git a/lib/pages/communities_list.dart b/lib/pages/communities_list.dart index 72c9d82..93f2ca6 100644 --- a/lib/pages/communities_list.dart +++ b/lib/pages/communities_list.dart @@ -11,8 +11,11 @@ class CommunitiesListPage extends StatelessWidget { final String title; final FetcherWithSorting fetcher; - const CommunitiesListPage({Key? key, required this.fetcher, this.title = ''}) - : super(key: key); + const CommunitiesListPage({ + super.key, + required this.fetcher, + this.title = '', + }); @override Widget build(BuildContext context) { @@ -42,8 +45,7 @@ class CommunitiesListPage extends StatelessWidget { class CommunitiesListItem extends StatelessWidget { final CommunityView community; - const CommunitiesListItem({Key? key, required this.community}) - : super(key: key); + const CommunitiesListItem({super.key, required this.community}); @override Widget build(BuildContext context) => ListTile( diff --git a/lib/pages/communities_tab.dart b/lib/pages/communities_tab.dart index 3aca777..d6bb871 100644 --- a/lib/pages/communities_tab.dart +++ b/lib/pages/communities_tab.dart @@ -241,9 +241,11 @@ class _CommunitySubscribeToggle extends HookWidget { final int communityId; final String instanceHost; - const _CommunitySubscribeToggle( - {required this.instanceHost, required this.communityId, Key? key}) - : super(key: key); + const _CommunitySubscribeToggle({ + required this.instanceHost, + required this.communityId, + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/pages/community/community_about_tab.dart b/lib/pages/community/community_about_tab.dart index a9462cc..954a738 100644 --- a/lib/pages/community/community_about_tab.dart +++ b/lib/pages/community/community_about_tab.dart @@ -15,8 +15,7 @@ import 'community_store.dart'; class CommmunityAboutTab extends StatelessWidget { final FullCommunityView fullCommunityView; - const CommmunityAboutTab(this.fullCommunityView, {Key? key}) - : super(key: key); + const CommmunityAboutTab(this.fullCommunityView, {super.key}); @override Widget build(BuildContext context) { diff --git a/lib/pages/community/community_more_menu.dart b/lib/pages/community/community_more_menu.dart index eb241b3..87834ca 100644 --- a/lib/pages/community/community_more_menu.dart +++ b/lib/pages/community/community_more_menu.dart @@ -14,8 +14,7 @@ import 'community_store.dart'; class CommunityMoreMenu extends HookWidget { final FullCommunityView fullCommunityView; - const CommunityMoreMenu({Key? key, required this.fullCommunityView}) - : super(key: key); + const CommunityMoreMenu({super.key, required this.fullCommunityView}); @override Widget build(BuildContext context) { diff --git a/lib/pages/create_post/create_post_community_picker.dart b/lib/pages/create_post/create_post_community_picker.dart index 4efc418..5082ecd 100644 --- a/lib/pages/create_post/create_post_community_picker.dart +++ b/lib/pages/create_post/create_post_community_picker.dart @@ -13,7 +13,7 @@ import '../../widgets/avatar.dart'; import 'create_post_store.dart'; class CreatePostCommunityPicker extends HookWidget { - const CreatePostCommunityPicker({Key? key}) : super(key: key); + const CreatePostCommunityPicker({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/pages/create_post/create_post_instance_picker.dart b/lib/pages/create_post/create_post_instance_picker.dart index 641aa50..dca166f 100644 --- a/lib/pages/create_post/create_post_instance_picker.dart +++ b/lib/pages/create_post/create_post_instance_picker.dart @@ -6,7 +6,7 @@ import '../../widgets/radio_picker.dart'; import 'create_post_store.dart'; class CreatePostInstancePicker extends StatelessWidget { - const CreatePostInstancePicker({Key? key}) : super(key: key); + const CreatePostInstancePicker({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/pages/full_post/comment_section.dart b/lib/pages/full_post/comment_section.dart index f34d909..d875779 100644 --- a/lib/pages/full_post/comment_section.dart +++ b/lib/pages/full_post/comment_section.dart @@ -27,7 +27,7 @@ class CommentSection extends StatelessWidget { CommentSortType.chat: _SortSelection(Icons.chat, L10nStrings.chat), }; - const CommentSection({Key? key}) : super(key: key); + const CommentSection({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/pages/instance/instance_more_menu.dart b/lib/pages/instance/instance_more_menu.dart index eee6fda..3558120 100644 --- a/lib/pages/instance/instance_more_menu.dart +++ b/lib/pages/instance/instance_more_menu.dart @@ -11,7 +11,7 @@ import '../../widgets/info_table_popup.dart'; class InstanceMoreMenu extends StatelessWidget { final FullSiteView site; - const InstanceMoreMenu({Key? key, required this.site}) : super(key: key); + const InstanceMoreMenu({super.key, required this.site}); @override Widget build(BuildContext context) { diff --git a/lib/pages/manage_account.dart b/lib/pages/manage_account.dart index 60871eb..e9a5121 100644 --- a/lib/pages/manage_account.dart +++ b/lib/pages/manage_account.dart @@ -86,7 +86,7 @@ class ManageAccountPage extends HookWidget { } class _ManageAccount extends HookWidget { - const _ManageAccount({Key? key, required this.user}) : super(key: key); + const _ManageAccount({required this.user}); final LocalUserSettingsView user; @@ -396,13 +396,12 @@ class _ImagePicker extends HookWidget { final ObjectRef informAcceptedRef; const _ImagePicker({ - Key? key, required this.initialUrl, required this.name, required this.user, required this.onChange, required this.informAcceptedRef, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/pages/modlog/modlog_table.dart b/lib/pages/modlog/modlog_table.dart index fb24363..ec71778 100644 --- a/lib/pages/modlog/modlog_table.dart +++ b/lib/pages/modlog/modlog_table.dart @@ -8,7 +8,7 @@ import '../../widgets/avatar.dart'; import 'modlog_entry.dart'; class ModlogTable extends StatelessWidget { - const ModlogTable({Key? key, required this.modlog}) : super(key: key); + const ModlogTable({super.key, required this.modlog}); final Modlog modlog; diff --git a/lib/pages/settings/blocks/block_tile.dart b/lib/pages/settings/blocks/block_tile.dart index 7fd0cc0..5c54671 100644 --- a/lib/pages/settings/blocks/block_tile.dart +++ b/lib/pages/settings/blocks/block_tile.dart @@ -10,7 +10,7 @@ import 'community_block_store.dart'; import 'user_block_store.dart'; class BlockPersonTile extends StatelessWidget { - const BlockPersonTile({Key? key}) : super(key: key); + const BlockPersonTile({super.key}); @override Widget build(BuildContext context) { @@ -40,7 +40,7 @@ class BlockPersonTile extends StatelessWidget { } class BlockCommunityTile extends HookWidget { - const BlockCommunityTile({Key? key}) : super(key: key); + const BlockCommunityTile({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index 33ac426..8cbc4eb 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -185,10 +185,9 @@ class _AccountOptions extends HookWidget { final String username; const _AccountOptions({ - Key? key, required this.instanceHost, required this.username, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/pages/users_list.dart b/lib/pages/users_list.dart index 15d1ea5..fa35047 100644 --- a/lib/pages/users_list.dart +++ b/lib/pages/users_list.dart @@ -12,8 +12,7 @@ class UsersListPage extends StatelessWidget { final String title; final Fetcher fetcher; - const UsersListPage({Key? key, required this.fetcher, this.title = ''}) - : super(key: key); + const UsersListPage({super.key, required this.fetcher, this.title = ''}); @override Widget build(BuildContext context) { @@ -41,7 +40,7 @@ class UsersListPage extends StatelessWidget { class UsersListItem extends StatelessWidget { final PersonViewSafe user; - const UsersListItem({Key? key, required this.user}) : super(key: key); + const UsersListItem({super.key, required this.user}); @override Widget build(BuildContext context) { diff --git a/lib/util/async_store_listener.dart b/lib/util/async_store_listener.dart index 88e4286..5ff1151 100644 --- a/lib/util/async_store_listener.dart +++ b/lib/util/async_store_listener.dart @@ -18,12 +18,12 @@ class AsyncStoreListener extends SingleChildStatelessWidget { )? onSuccess; const AsyncStoreListener({ - Key? key, + super.key, required this.asyncStore, this.successMessageBuilder, this.onSuccess, - Widget? child, - }) : super(key: key, child: child); + super.child, + }); @override Widget buildWithChild(BuildContext context, Widget? child) { diff --git a/lib/util/goto.dart b/lib/util/goto.dart index 7298816..037f5f7 100644 --- a/lib/util/goto.dart +++ b/lib/util/goto.dart @@ -59,7 +59,6 @@ void goToMedia(BuildContext context, String url) => Navigator.push( context, PageRouteBuilder( pageBuilder: (_, __, ___) => MediaViewPage(url), - transitionDuration: const Duration(milliseconds: 300), opaque: false, transitionsBuilder: (_, animation, __, child) => FadeTransition(opacity: animation, child: child), diff --git a/lib/util/mobx_provider.dart b/lib/util/mobx_provider.dart index 7afca1d..42e1684 100644 --- a/lib/util/mobx_provider.dart +++ b/lib/util/mobx_provider.dart @@ -8,34 +8,24 @@ import 'observer_consumers.dart'; /// Important: this will not make [context.watch] react to changes class MobxProvider extends Provider { MobxProvider({ - Key? key, - required Create create, - bool? lazy, - TransitionBuilder? builder, - Widget? child, + super.key, + required super.create, + super.lazy, + super.builder, + super.child, }) : super( - key: key, - create: create, dispose: (context, store) { if (store is DisposableStore) store.dispose(); }, - lazy: lazy, - builder: builder, - child: child, ); /// will not dispose the store MobxProvider.value({ - Key? key, - required T value, - TransitionBuilder? builder, - Widget? child, - }) : super.value( - key: key, - builder: builder, - value: value, - child: child, - ); + super.key, + required super.value, + super.builder, + super.child, + }) : super.value(); } /// tracks reactions and disposes them in [DisposableStore.dispose] diff --git a/lib/util/observer_consumers.dart b/lib/util/observer_consumers.dart index 56f645f..c157a18 100644 --- a/lib/util/observer_consumers.dart +++ b/lib/util/observer_consumers.dart @@ -14,10 +14,10 @@ class ObserverBuilder extends StatelessWidget { final MobxBuilder builder; const ObserverBuilder({ - Key? key, + super.key, this.store, required this.builder, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -38,11 +38,11 @@ class ObserverListener extends HookWidget { final Widget child; const ObserverListener({ - Key? key, + super.key, this.store, required this.listener, required this.child, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -64,11 +64,11 @@ class ObserverConsumer extends HookWidget { final MobxBuilder builder; const ObserverConsumer({ - Key? key, + super.key, this.store, required this.listener, required this.builder, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/about_tile.dart b/lib/widgets/about_tile.dart index 021a6c0..36085dc 100644 --- a/lib/widgets/about_tile.dart +++ b/lib/widgets/about_tile.dart @@ -96,7 +96,7 @@ class AboutTile extends HookWidget { class ChangelogPage extends StatelessWidget { final String changelog; - const ChangelogPage(this.changelog, {Key? key}) : super(key: key); + const ChangelogPage(this.changelog, {super.key}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/avatar.dart b/lib/widgets/avatar.dart index 0499810..d9fe815 100644 --- a/lib/widgets/avatar.dart +++ b/lib/widgets/avatar.dart @@ -10,14 +10,14 @@ import 'cached_network_image.dart'; /// Can be disabled with `noBlank` class Avatar extends HookWidget { const Avatar({ - Key? key, + super.key, required this.url, this.radius = 25, this.noBlank = false, this.alwaysShow = false, this.padding = EdgeInsets.zero, this.onTap, - }) : super(key: key); + }); final String? url; final double radius; diff --git a/lib/widgets/cached_network_image.dart b/lib/widgets/cached_network_image.dart index 6886315..831fd8b 100644 --- a/lib/widgets/cached_network_image.dart +++ b/lib/widgets/cached_network_image.dart @@ -41,8 +41,8 @@ class CachedNetworkImage extends StatelessWidget { this.width, this.fit, this.cache = true, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/comment/comment.dart b/lib/widgets/comment/comment.dart index b0faa80..9bc0d01 100644 --- a/lib/widgets/comment/comment.dart +++ b/lib/widgets/comment/comment.dart @@ -35,8 +35,8 @@ class CommentWidget extends StatelessWidget { this.canBeMarkedAsRead = false, this.hideOnRead = false, this.userMentionId, - Key? key, - }) : super(key: key); + super.key, + }); CommentWidget.fromCommentView( CommentView cv, { diff --git a/lib/widgets/comment/comment_actions.dart b/lib/widgets/comment/comment_actions.dart index 6aff5df..6b21057 100644 --- a/lib/widgets/comment/comment_actions.dart +++ b/lib/widgets/comment/comment_actions.dart @@ -13,7 +13,7 @@ import 'comment_more_menu_button.dart'; import 'comment_store.dart'; class CommentActions extends HookWidget { - const CommentActions({Key? key}) : super(key: key); + const CommentActions({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/comment/comment_more_menu_button.dart b/lib/widgets/comment/comment_more_menu_button.dart index 9d51139..7e41ffd 100644 --- a/lib/widgets/comment/comment_more_menu_button.dart +++ b/lib/widgets/comment/comment_more_menu_button.dart @@ -18,7 +18,7 @@ import 'comment.dart'; import 'comment_store.dart'; class CommentMoreMenuButton extends HookWidget { - const CommentMoreMenuButton({Key? key}) : super(key: key); + const CommentMoreMenuButton({super.key}); @override Widget build(BuildContext context) { @@ -44,9 +44,8 @@ class _CommentMoreMenuPopup extends HookWidget { final CommentStore store; const _CommentMoreMenuPopup({ - Key? key, required this.store, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/editor.dart b/lib/widgets/editor.dart index f4d8a1f..145ab94 100644 --- a/lib/widgets/editor.dart +++ b/lib/widgets/editor.dart @@ -20,7 +20,7 @@ class Editor extends HookWidget { final String instanceHost; const Editor({ - Key? key, + super.key, this.controller, this.focusNode, this.onSubmitted, @@ -32,7 +32,7 @@ class Editor extends HookWidget { this.fancy = false, required this.instanceHost, this.autofocus = false, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/fullscreenable_image.dart b/lib/widgets/fullscreenable_image.dart index a6aa4cb..fac40b4 100644 --- a/lib/widgets/fullscreenable_image.dart +++ b/lib/widgets/fullscreenable_image.dart @@ -9,10 +9,10 @@ class FullscreenableImage extends StatelessWidget { final Widget child; const FullscreenableImage({ - Key? key, + super.key, required this.url, required this.child, - }) : super(key: key); + }); @override Widget build(BuildContext context) => InkWell( diff --git a/lib/widgets/pull_to_refresh.dart b/lib/widgets/pull_to_refresh.dart index 58bfcf6..fe7daad 100644 --- a/lib/widgets/pull_to_refresh.dart +++ b/lib/widgets/pull_to_refresh.dart @@ -6,10 +6,10 @@ class PullToRefresh extends StatelessWidget { final Widget child; const PullToRefresh({ - Key? key, + super.key, required this.onRefresh, required this.child, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/radio_picker.dart b/lib/widgets/radio_picker.dart index 2f10058..3c2a3e1 100644 --- a/lib/widgets/radio_picker.dart +++ b/lib/widgets/radio_picker.dart @@ -20,7 +20,7 @@ class RadioPicker extends StatelessWidget { final Widget? trailing; const RadioPicker({ - Key? key, + super.key, required this.values, required this.groupValue, required this.onChanged, @@ -28,7 +28,7 @@ class RadioPicker extends StatelessWidget { this.buttonBuilder, this.title, this.trailing, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/sortable_infinite_list.dart b/lib/widgets/sortable_infinite_list.dart index 4991bfd..de322ef 100644 --- a/lib/widgets/sortable_infinite_list.dart +++ b/lib/widgets/sortable_infinite_list.dart @@ -70,8 +70,8 @@ class SortableInfiniteList extends HookWidget { class InfinitePostList extends SortableInfiniteList { InfinitePostList({ - required FetcherWithSorting fetcher, - InfiniteScrollController? controller, + required super.fetcher, + super.controller, }) : super( itemBuilder: (post) => Column( children: [ @@ -79,8 +79,6 @@ class InfinitePostList extends SortableInfiniteList { const SizedBox(height: 20), ], ), - fetcher: fetcher, - controller: controller, noItems: const Text('there are no posts'), uniqueProp: (item) => item.post.apId, ); @@ -88,15 +86,13 @@ class InfinitePostList extends SortableInfiniteList { class InfiniteCommentList extends SortableInfiniteList { InfiniteCommentList({ - required FetcherWithSorting fetcher, - InfiniteScrollController? controller, + required super.fetcher, + super.controller, }) : super( itemBuilder: (comment) => CommentWidget( CommentTree(comment), detached: true, ), - fetcher: fetcher, - controller: controller, noItems: const Text('there are no comments'), uniqueProp: (item) => item.comment.apId, ); diff --git a/lib/widgets/tile_action.dart b/lib/widgets/tile_action.dart index 294aae3..c073254 100644 --- a/lib/widgets/tile_action.dart +++ b/lib/widgets/tile_action.dart @@ -14,14 +14,14 @@ class TileAction extends StatelessWidget { final Color? iconColor; const TileAction({ - Key? key, + super.key, this.delayedLoading, this.iconColor, required this.icon, required this.onPressed, required this.tooltip, this.loading = false, - }) : super(key: key); + }); @override Widget build(BuildContext context) => IconButton( diff --git a/lib/widgets/user_tile.dart b/lib/widgets/user_tile.dart index 2b0a444..6a53079 100644 --- a/lib/widgets/user_tile.dart +++ b/lib/widgets/user_tile.dart @@ -12,8 +12,8 @@ class PersonTile extends StatelessWidget { const PersonTile( this.person, { this.expanded = false, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) {