From 0590fe1a76925c80b0af13bb44729fd8930dee5e Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 5 May 2021 19:07:32 +0530 Subject: [PATCH] lint --- .../lib/src/attachment/attachment_widget.dart | 1 + .../lib/src/attachment/file_attachment.dart | 4 +- .../lib/src/attachment_actions_modal.dart | 42 +++++++++---------- .../lib/src/channel_image.dart | 2 +- .../lib/src/channel_info.dart | 4 +- .../lib/src/mention_tile.dart | 2 +- .../lib/src/message_text.dart | 2 - .../lib/src/user_list_view.dart | 2 - .../stream_chat_flutter/lib/src/utils.dart | 6 +-- .../lib/src/video_service.dart | 2 +- packages/stream_chat_flutter/pubspec.yaml | 6 +-- .../src/attachment_actions_modal_test.dart | 7 ++-- .../test/src/back_button_test.dart | 2 +- .../test/src/reaction_bubble_test.dart | 16 +++---- .../test/src/simple_frame.dart | 22 +++++----- .../test/src/system_message_test.dart | 4 +- .../test/src/thread_header_test.dart | 8 ++-- .../test/src/typing_indicator_test.dart | 4 +- .../test/src/unread_indicator_test.dart | 2 +- 19 files changed, 68 insertions(+), 70 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart index 74769057..ee79d959 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart @@ -67,6 +67,7 @@ class AttachmentError extends StatelessWidget { this.size, }) : super(key: key); + /// Size of error final Size? size; @override diff --git a/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart index c68d72f9..63bcdd9b 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart @@ -6,10 +6,12 @@ import 'package:stream_chat_flutter/src/stream_svg_icon.dart'; import 'package:stream_chat_flutter/src/utils.dart'; import 'package:stream_chat_flutter/src/video_thumbnail_image.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; +import 'package:stream_chat_flutter/src/upload_progress_indicator.dart'; -import '../upload_progress_indicator.dart'; +// ignore: always_use_package_imports import 'attachment_widget.dart'; +/// Widget for displaying file attachments class FileAttachment extends AttachmentWidget { /// Constructor for creating a widget when attachment is of type 'file' const FileAttachment({ diff --git a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart index a9ea651b..363fac45 100644 --- a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart @@ -5,9 +5,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:image_gallery_saver/image_gallery_saver.dart'; import 'package:path_provider/path_provider.dart'; - -import '../stream_chat_flutter.dart'; -import 'extension.dart'; +import 'package:stream_chat_flutter/src/extension.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// Callback to download an attachment asset typedef AttachmentDownloader = Future Function( @@ -17,6 +16,16 @@ typedef AttachmentDownloader = Future Function( /// Widget that shows the options in the gallery view class AttachmentActionsModal extends StatelessWidget { + /// Returns a new [AttachmentActionsModal] + const AttachmentActionsModal({ + Key? key, + required this.currentIndex, + required this.message, + this.onShowMessage, + this.imageDownloader, + this.fileDownloader, + }) : super(key: key); + /// The message containing the attachments final Message message; @@ -32,15 +41,6 @@ class AttachmentActionsModal extends StatelessWidget { /// Callback to provide download files final AttachmentDownloader? fileDownloader; - /// Returns a new [AttachmentActionsModal] - const AttachmentActionsModal({ - required this.currentIndex, - required this.message, - this.onShowMessage, - this.imageDownloader, - this.fileDownloader, - }); - @override Widget build(BuildContext context) => GestureDetector( behavior: HitTestBehavior.translucent, @@ -62,7 +62,7 @@ class AttachmentActionsModal extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), ), - child: Container( + child: SizedBox( child: Column( crossAxisAlignment: CrossAxisAlignment.end, mainAxisSize: MainAxisSize.min, @@ -89,6 +89,7 @@ class AttachmentActionsModal extends StatelessWidget { ), _buildButton( context, + // ignore: lines_longer_than_80_chars 'Save ${message.attachments[currentIndex].type == 'video' ? 'Video' : 'Image'}', StreamSvgIcon.iconSave( size: 24, @@ -203,7 +204,7 @@ class AttachmentActionsModal extends StatelessWidget { child: Row( children: [ icon, - SizedBox(width: 16), + const SizedBox(width: 16), Text( title, style: StreamChatTheme.of(context) @@ -253,7 +254,7 @@ class AttachmentActionsModal extends StatelessWidget { ) : progress.toProgressIndicatorValue == 1.0 ? SizedBox( - key: Key('completedIcon'), + key: const Key('completedIcon'), height: 160, width: 160, child: StreamSvgIcon.check( @@ -314,14 +315,13 @@ class AttachmentActionsModal extends StatelessWidget { } class _DownloadProgress { - final int total; - final int received; - const _DownloadProgress(this.total, this.received); - factory _DownloadProgress.initial() { - return _DownloadProgress(double.maxFinite.toInt(), 0); - } + factory _DownloadProgress.initial() => + _DownloadProgress(double.maxFinite.toInt(), 0); + + final int total; + final int received; double get toProgressIndicatorValue => received / total; diff --git a/packages/stream_chat_flutter/lib/src/channel_image.dart b/packages/stream_chat_flutter/lib/src/channel_image.dart index 8116ca83..80e32f07 100644 --- a/packages/stream_chat_flutter/lib/src/channel_image.dart +++ b/packages/stream_chat_flutter/lib/src/channel_image.dart @@ -196,7 +196,7 @@ class ChannelImage extends StatelessWidget { ); if (selected) { child = ClipRRect( - key: Key('selectedImage'), + key: const Key('selectedImage'), borderRadius: (borderRadius ?? StreamChatTheme.of(context) .ownMessageTheme diff --git a/packages/stream_chat_flutter/lib/src/channel_info.dart b/packages/stream_chat_flutter/lib/src/channel_info.dart index 72f6cf18..5fa6f704 100644 --- a/packages/stream_chat_flutter/lib/src/channel_info.dart +++ b/packages/stream_chat_flutter/lib/src/channel_info.dart @@ -3,9 +3,9 @@ import 'package:flutter/material.dart'; import 'package:jiffy/jiffy.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'connection_status_builder.dart'; - +/// Widget which shows channel info class ChannelInfo extends StatelessWidget { + /// Constructor which creates a [ChannelInfo] widget const ChannelInfo({ Key? key, required this.channel, diff --git a/packages/stream_chat_flutter/lib/src/mention_tile.dart b/packages/stream_chat_flutter/lib/src/mention_tile.dart index e8859946..f3bed355 100644 --- a/packages/stream_chat_flutter/lib/src/mention_tile.dart +++ b/packages/stream_chat_flutter/lib/src/mention_tile.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../stream_chat_flutter.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// This widget is used for showing user tiles for mentions /// Use [title], [subtitle], [leading], [trailing] for diff --git a/packages/stream_chat_flutter/lib/src/message_text.dart b/packages/stream_chat_flutter/lib/src/message_text.dart index 8c95120d..24a32a09 100644 --- a/packages/stream_chat_flutter/lib/src/message_text.dart +++ b/packages/stream_chat_flutter/lib/src/message_text.dart @@ -4,8 +4,6 @@ import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import '../stream_chat_flutter.dart'; - /// Text widget to display in message class MessageText extends StatelessWidget { /// Constructor for creating a [MessageText] widget diff --git a/packages/stream_chat_flutter/lib/src/user_list_view.dart b/packages/stream_chat_flutter/lib/src/user_list_view.dart index 0c835fbe..4d5d202a 100644 --- a/packages/stream_chat_flutter/lib/src/user_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/user_list_view.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; -import 'user_item.dart'; - /// Callback called when tapping on a user typedef UserTapCallback = void Function(User, Widget?); diff --git a/packages/stream_chat_flutter/lib/src/utils.dart b/packages/stream_chat_flutter/lib/src/utils.dart index 8f493cec..cdd87e2d 100644 --- a/packages/stream_chat_flutter/lib/src/utils.dart +++ b/packages/stream_chat_flutter/lib/src/utils.dart @@ -3,10 +3,9 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import '../stream_chat_flutter.dart'; -import 'stream_svg_icon.dart'; - +/// Launch URL Future launchURL(BuildContext context, String? url) async { if (url != null && await canLaunch(url)) { await launch(url); @@ -20,6 +19,7 @@ Future launchURL(BuildContext context, String? url) async { } } +/// Shows confirmation dialog Future showConfirmationDialog( BuildContext context, { required String title, diff --git a/packages/stream_chat_flutter/lib/src/video_service.dart b/packages/stream_chat_flutter/lib/src/video_service.dart index 3b6bb13e..ba4761a2 100644 --- a/packages/stream_chat_flutter/lib/src/video_service.dart +++ b/packages/stream_chat_flutter/lib/src/video_service.dart @@ -60,6 +60,6 @@ class IVideoService { ); } -// ignore: non_constant_identifier_names /// Get instance of [IVideoService] +// ignore: non_constant_identifier_names IVideoService get VideoService => IVideoService.instance; diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 7a2725ed..2ef87189 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -12,10 +12,10 @@ dependencies: flutter: sdk: flutter stream_chat_flutter_core: ^2.0.0-nullsafety.0 - photo_view: ^0.11.1 rxdart: ^0.26.0 scrollable_positioned_list: ^0.2.0-nullsafety.0 jiffy: ^4.1.0 + photo_view: ^0.11.1 flutter_svg: ^0.22.0 flutter_portal: ^0.4.0 cached_network_image: ^3.0.0 @@ -57,6 +57,6 @@ dev_dependencies: flutter_test: sdk: flutter mocktail: ^0.1.2 - pedantic: ^1.11.0 golden_toolkit: ^0.9.0 - + pedantic: ^1.11.0 + diff --git a/packages/stream_chat_flutter/test/src/attachment_actions_modal_test.dart b/packages/stream_chat_flutter/test/src/attachment_actions_modal_test.dart index 51ca5c57..3f210742 100644 --- a/packages/stream_chat_flutter/test/src/attachment_actions_modal_test.dart +++ b/packages/stream_chat_flutter/test/src/attachment_actions_modal_test.dart @@ -23,7 +23,8 @@ class MockAttachmentDownloader extends Mock { void main() { setUpAll(() { - registerFallbackValue(MaterialPageRoute(builder: (context) => SizedBox())); + registerFallbackValue( + MaterialPageRoute(builder: (context) => const SizedBox())); registerFallbackValue(Message()); }); @@ -461,9 +462,9 @@ void main() { MaterialApp( builder: (context, child) => StreamChat( client: client, - child: child!, + child: child, ), - home: Container( + home: SizedBox( child: AttachmentActionsModal( fileDownloader: fileDownloader, message: Message( diff --git a/packages/stream_chat_flutter/test/src/back_button_test.dart b/packages/stream_chat_flutter/test/src/back_button_test.dart index b991a01e..3fae1ace 100644 --- a/packages/stream_chat_flutter/test/src/back_button_test.dart +++ b/packages/stream_chat_flutter/test/src/back_button_test.dart @@ -19,7 +19,7 @@ void main() { child: Center( child: StreamChatTheme( data: StreamChatThemeData.fromTheme(theme), - child: StreamBackButton(), + child: const StreamBackButton(), ), ), ), diff --git a/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart b/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart index 8d575746..770a040b 100644 --- a/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart +++ b/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart @@ -26,7 +26,7 @@ void main() { ), ), ), - surfaceSize: Size(100, 100), + surfaceSize: const Size(100, 100), ); await screenMatchesGolden(tester, 'reaction_bubble_0'); }, @@ -47,7 +47,7 @@ void main() { StreamChat( client: client, streamChatThemeData: theme, - child: Container( + child: SizedBox( child: ReactionBubble( reactions: [ Reaction( @@ -61,7 +61,7 @@ void main() { ), ), ), - surfaceSize: Size(100, 100), + surfaceSize: const Size(100, 100), ); await screenMatchesGolden(tester, 'reaction_bubble_like_light'); }, @@ -97,7 +97,7 @@ void main() { ), ), ), - surfaceSize: Size(100, 100), + surfaceSize: const Size(100, 100), ); await screenMatchesGolden(tester, 'reaction_bubble_like_dark'); }, @@ -141,7 +141,7 @@ void main() { ), ), ), - surfaceSize: Size(140, 140), + surfaceSize: const Size(140, 140), ); await screenMatchesGolden(tester, 'reaction_bubble_3_light'); }, @@ -185,7 +185,7 @@ void main() { ), ), ), - surfaceSize: Size(140, 140), + surfaceSize: const Size(140, 140), ); await screenMatchesGolden(tester, 'reaction_bubble_3_dark'); }, @@ -205,7 +205,7 @@ void main() { StreamChat( client: client, streamChatThemeData: StreamChatThemeData.fromTheme(themeData), - child: Container( + child: SizedBox( child: ReactionBubble( reactions: [ Reaction( @@ -230,7 +230,7 @@ void main() { ), ), ), - surfaceSize: Size(200, 200), + surfaceSize: const Size(200, 200), ); await screenMatchesGolden(tester, 'reaction_bubble_2'); diff --git a/packages/stream_chat_flutter/test/src/simple_frame.dart b/packages/stream_chat_flutter/test/src/simple_frame.dart index 18d7ae55..0633a3b8 100644 --- a/packages/stream_chat_flutter/test/src/simple_frame.dart +++ b/packages/stream_chat_flutter/test/src/simple_frame.dart @@ -1,19 +1,17 @@ import 'package:flutter/material.dart'; class SimpleFrame extends StatelessWidget { - final Widget child; - const SimpleFrame({Key? key, required this.child}) : super(key: key); + final Widget child; + @override - Widget build(BuildContext context) { - return Container( - padding: const EdgeInsets.all(4), - decoration: BoxDecoration( - color: const Color(0xFFFFFFFF), - border: Border.all(color: const Color(0xFF9E9E9E)), - ), - child: child, - ); - } + Widget build(BuildContext context) => Container( + padding: const EdgeInsets.all(4), + decoration: BoxDecoration( + color: const Color(0xFFFFFFFF), + border: Border.all(color: const Color(0xFF9E9E9E)), + ), + child: child, + ); } diff --git a/packages/stream_chat_flutter/test/src/system_message_test.dart b/packages/stream_chat_flutter/test/src/system_message_test.dart index 53741864..8fa3ad44 100644 --- a/packages/stream_chat_flutter/test/src/system_message_test.dart +++ b/packages/stream_chat_flutter/test/src/system_message_test.dart @@ -102,7 +102,7 @@ void main() { ), ), ), - surfaceSize: Size.square(200), + surfaceSize: const Size.square(200), ); await screenMatchesGolden(tester, 'system_message_light'); @@ -153,7 +153,7 @@ void main() { ), ), ), - surfaceSize: Size.square(200), + surfaceSize: const Size.square(200), ); await screenMatchesGolden(tester, 'system_message_dark'); diff --git a/packages/stream_chat_flutter/test/src/thread_header_test.dart b/packages/stream_chat_flutter/test/src/thread_header_test.dart index 9e64abb7..578b2ad6 100644 --- a/packages/stream_chat_flutter/test/src/thread_header_test.dart +++ b/packages/stream_chat_flutter/test/src/thread_header_test.dart @@ -117,13 +117,13 @@ void main() { child: Scaffold( body: ThreadHeader( parent: Message(), - subtitle: Text('subtitle'), - leading: Text('leading'), - title: Text('title'), + subtitle: const Text('subtitle'), + leading: const Text('leading'), + title: const Text('title'), onTitleTap: () { tapped = true; }, - actions: [ + actions: const [ Text('action'), ], ), diff --git a/packages/stream_chat_flutter/test/src/typing_indicator_test.dart b/packages/stream_chat_flutter/test/src/typing_indicator_test.dart index 8698de91..cc9af663 100644 --- a/packages/stream_chat_flutter/test/src/typing_indicator_test.dart +++ b/packages/stream_chat_flutter/test/src/typing_indicator_test.dart @@ -67,14 +67,14 @@ void main() { client: client, child: StreamChannel( channel: channel, - child: Scaffold( + child: const Scaffold( body: TypingIndicator(), ), ), ), )); - expect(find.byKey(Key('typings')), findsOneWidget); + expect(find.byKey(const Key('typings')), findsOneWidget); }, ); } diff --git a/packages/stream_chat_flutter/test/src/unread_indicator_test.dart b/packages/stream_chat_flutter/test/src/unread_indicator_test.dart index 9b1b5e1e..29bc0d79 100644 --- a/packages/stream_chat_flutter/test/src/unread_indicator_test.dart +++ b/packages/stream_chat_flutter/test/src/unread_indicator_test.dart @@ -36,7 +36,7 @@ void main() { client: client, child: StreamChannel( channel: channel, - child: Scaffold( + child: const Scaffold( body: UnreadIndicator(), ), ),