diff --git a/analysis_options.yaml b/analysis_options.yaml index 0e1a55c5c..0deff3a07 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -27,4 +27,24 @@ dart_code_linter: - avoid-unnecessary-type-assertions - avoid-unnecessary-type-casts - avoid-unrelated-type-assertions - - no-boolean-literal-compare \ No newline at end of file + - no-boolean-literal-compare + - no-equal-then-else + - prefer-first + - prefer-last + - prefer-immediate-return + - prefer-enums-by-name + - avoid-unnecessary-conditionals + # TODO: + # - member-ordering + # - avoid-late-keyword + # - avoid-non-null-assertion + # - avoid-global-state + # - prefer-match-file-name + # - avoid-banned-imports: + # entries: + # - paths: ['some/folder/.*\.dart', 'another/folder/.*\.dart'] + # deny: ['package:flutter/material.dart'] + # message: 'Do not import Flutter Material Design library, we should not depend on it!' + # - no-magic-number: + # allowed: [-1, 0, 1,2,4,6,8,12,16,32,40,56,64] + # allow-only-once: true \ No newline at end of file diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index a6e52549a..de967b581 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -159,7 +159,7 @@ class InputBar extends StatelessWidget { slugify( user.displayName!.toLowerCase(), ).contains(userSearch))) || - user.id.split(':')[0].toLowerCase().contains(userSearch)) { + user.id.localpart!.toLowerCase().contains(userSearch)) { ret.add({ 'type': 'user', 'mxid': user.id, @@ -185,17 +185,14 @@ class InputBar extends StatelessWidget { ((state.content['alias'] is String && state.content .tryGet('alias')! - .split(':')[0] + .localpart! .toLowerCase() .contains(roomSearch)) || (state.content['alt_aliases'] is List && (state.content['alt_aliases'] as List).any( (l) => l is String && - l - .split(':')[0] - .toLowerCase() - .contains(roomSearch), + l.localpart!.toLowerCase().contains(roomSearch), )))) || (r.name.toLowerCase().contains(roomSearch))) { ret.add({ diff --git a/lib/pages/dialer/dialer.dart b/lib/pages/dialer/dialer.dart index 85c10f7d9..2b0212748 100644 --- a/lib/pages/dialer/dialer.dart +++ b/lib/pages/dialer/dialer.dart @@ -147,7 +147,7 @@ class MyCallingPage extends State { MediaStream? get remoteStream { if (call.getRemoteStreams.isNotEmpty) { - return call.getRemoteStreams[0].stream!; + return call.getRemoteStreams.first.stream!; } return null; } @@ -327,7 +327,7 @@ class MyCallingPage extends State { void _switchCamera() async { if (call.localUserMediaStream != null) { await Helper.switchCamera( - call.localUserMediaStream!.stream!.getVideoTracks()[0], + call.localUserMediaStream!.stream!.getVideoTracks().first, ); } setState(() {}); diff --git a/lib/pages/key_verification/key_verification_dialog.dart b/lib/pages/key_verification/key_verification_dialog.dart index 10121f9b9..400b3e6c9 100644 --- a/lib/pages/key_verification/key_verification_dialog.dart +++ b/lib/pages/key_verification/key_verification_dialog.dart @@ -248,7 +248,7 @@ class KeyVerificationPageState extends State { } else { title = Text(L10n.of(context).compareNumbersMatch); final numbers = widget.request.sasNumbers; - final numbstr = '${numbers[0]}-${numbers[1]}-${numbers[2]}'; + final numbstr = '${numbers.first}-${numbers[1]}-${numbers[2]}'; compareWidget = TextSpan( text: numbstr, style: const TextStyle(fontSize: 40), diff --git a/lib/utils/push_helper.dart b/lib/utils/push_helper.dart index 0fdc9565f..4b10623e3 100644 --- a/lib/utils/push_helper.dart +++ b/lib/utils/push_helper.dart @@ -340,7 +340,7 @@ class FluffyChatPushPayload { if (parts.length != 3) { return FluffyChatPushPayload(null, null, null); } - return FluffyChatPushPayload(parts[0], parts[1], parts[2]); + return FluffyChatPushPayload(parts.first, parts[1], parts[2]); } @override