Enable new lints

This commit is contained in:
shilangyu 2022-05-11 22:23:18 +02:00
parent 3f33cac3ed
commit 4533be634e
32 changed files with 74 additions and 90 deletions

View File

@ -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

View File

@ -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 {

View File

@ -11,8 +11,11 @@ class CommunitiesListPage extends StatelessWidget {
final String title;
final FetcherWithSorting<CommunityView> 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(

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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<VoidCallback?> 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) {

View File

@ -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;

View File

@ -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) {

View File

@ -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) {

View File

@ -12,8 +12,7 @@ class UsersListPage extends StatelessWidget {
final String title;
final Fetcher<PersonViewSafe> 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) {

View File

@ -18,12 +18,12 @@ class AsyncStoreListener<T> 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) {

View File

@ -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),

View File

@ -8,34 +8,24 @@ import 'observer_consumers.dart';
/// Important: this will not make [context.watch] react to changes
class MobxProvider<T extends Store> extends Provider<T> {
MobxProvider({
Key? key,
required Create<T> 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]

View File

@ -14,10 +14,10 @@ class ObserverBuilder<T extends Store> extends StatelessWidget {
final MobxBuilder<T> 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<T extends Store> 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<T extends Store> extends HookWidget {
final MobxBuilder<T> builder;
const ObserverConsumer({
Key? key,
super.key,
this.store,
required this.listener,
required this.builder,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {

View File

@ -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) {

View File

@ -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;

View File

@ -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) {

View File

@ -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, {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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(

View File

@ -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) {

View File

@ -20,7 +20,7 @@ class RadioPicker<T> 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<T> extends StatelessWidget {
this.buttonBuilder,
this.title,
this.trailing,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {

View File

@ -70,8 +70,8 @@ class SortableInfiniteList<T> extends HookWidget {
class InfinitePostList extends SortableInfiniteList<PostView> {
InfinitePostList({
required FetcherWithSorting<PostView> fetcher,
InfiniteScrollController? controller,
required super.fetcher,
super.controller,
}) : super(
itemBuilder: (post) => Column(
children: [
@ -79,8 +79,6 @@ class InfinitePostList extends SortableInfiniteList<PostView> {
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<PostView> {
class InfiniteCommentList extends SortableInfiniteList<CommentView> {
InfiniteCommentList({
required FetcherWithSorting<CommentView> 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,
);

View File

@ -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(

View File

@ -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) {