From ad86cf0cd698d2be4a990ddf34cb782b2b34d5f8 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 5 May 2021 17:49:49 +0530 Subject: [PATCH] lint --- .../lib/src/user_reaction_display.dart | 61 +++--- .../stream_chat_flutter/lib/src/utils.dart | 175 +++++++++--------- .../lib/src/video_thumbnail_image.dart | 13 +- 3 files changed, 126 insertions(+), 123 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/user_reaction_display.dart b/packages/stream_chat_flutter/lib/src/user_reaction_display.dart index 23c723dd..b5ef623e 100644 --- a/packages/stream_chat_flutter/lib/src/user_reaction_display.dart +++ b/packages/stream_chat_flutter/lib/src/user_reaction_display.dart @@ -4,7 +4,6 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; /// Displays a list of users who reacted class UserReactionDisplay extends StatelessWidget { - /// Constructor for creating a [UserReactionDisplay] const UserReactionDisplay({ Key? key, @@ -24,38 +23,38 @@ class UserReactionDisplay extends StatelessWidget { @override Widget build(BuildContext context) => Container( - color: Colors.black87, - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: reactionToEmoji.keys.map((reactionType) { - final firstUserReaction = message.latestReactions! - .firstWhere((element) => element.type == reactionType, - //ignore: unnecessary_parenthesis - orElse: (() => null) as Reaction Function()?); + color: Colors.black87, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: reactionToEmoji.keys.map((reactionType) { + final firstUserReaction = message.latestReactions! + .firstWhere((element) => element.type == reactionType, + //ignore: unnecessary_parenthesis + orElse: (() => null) as Reaction Function()?); + + if (firstUserReaction.user == null) { + return IconButton( + iconSize: size, + icon: Container(), + onPressed: null, + ); + } - if (firstUserReaction.user == null) { return IconButton( iconSize: size, - icon: Container(), - onPressed: null, - ); - } - - return IconButton( - iconSize: size, - icon: UserAvatar( - user: firstUserReaction.user!, - constraints: BoxConstraints( - maxHeight: size - 5, - maxWidth: size - 5, + icon: UserAvatar( + user: firstUserReaction.user!, + constraints: BoxConstraints( + maxHeight: size - 5, + maxWidth: size - 5, + ), + onTap: (user) {}, ), - onTap: (user) {}, - ), - onPressed: () {}, - ); - }).toList(), - ), - ); + onPressed: () {}, + ); + }).toList(), + ), + ); } diff --git a/packages/stream_chat_flutter/lib/src/utils.dart b/packages/stream_chat_flutter/lib/src/utils.dart index 11a1f3c0..8f493cec 100644 --- a/packages/stream_chat_flutter/lib/src/utils.dart +++ b/packages/stream_chat_flutter/lib/src/utils.dart @@ -27,88 +27,89 @@ Future showConfirmationDialog( Widget? icon, String? question, String? cancelText, -}) => showModalBottomSheet( - backgroundColor: StreamChatTheme.of(context).colorTheme.white, - context: context, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(16), - topRight: Radius.circular(16), - )), - builder: (context) { - final effect = StreamChatTheme.of(context).colorTheme.borderTop; - return SafeArea( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const SizedBox(height: 26), - if (icon != null) icon, - const SizedBox(height: 26), - Text( - title, - style: StreamChatTheme.of(context).textTheme.headlineBold, - ), - const SizedBox(height: 7), - if (question != null) +}) => + showModalBottomSheet( + backgroundColor: StreamChatTheme.of(context).colorTheme.white, + context: context, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + )), + builder: (context) { + final effect = StreamChatTheme.of(context).colorTheme.borderTop; + return SafeArea( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const SizedBox(height: 26), + if (icon != null) icon, + const SizedBox(height: 26), Text( - question, - textAlign: TextAlign.center, + title, + style: StreamChatTheme.of(context).textTheme.headlineBold, ), - const SizedBox(height: 36), - Container( - color: effect.color!.withOpacity(effect.alpha ?? 1), - height: 1, - ), - Row( - children: [ - if (cancelText != null) + const SizedBox(height: 7), + if (question != null) + Text( + question, + textAlign: TextAlign.center, + ), + const SizedBox(height: 36), + Container( + color: effect.color!.withOpacity(effect.alpha ?? 1), + height: 1, + ), + Row( + children: [ + if (cancelText != null) + Flexible( + child: Container( + alignment: Alignment.center, + child: TextButton( + onPressed: () { + Navigator.of(context).pop(false); + }, + child: Text( + cancelText, + style: StreamChatTheme.of(context) + .textTheme + .bodyBold + .copyWith( + color: StreamChatTheme.of(context) + .colorTheme + .black + .withOpacity(0.5)), + ), + ), + ), + ), Flexible( child: Container( alignment: Alignment.center, child: TextButton( onPressed: () { - Navigator.of(context).pop(false); + Navigator.pop(context, true); }, child: Text( - cancelText, + okText, style: StreamChatTheme.of(context) .textTheme .bodyBold .copyWith( color: StreamChatTheme.of(context) .colorTheme - .black - .withOpacity(0.5)), + .accentRed), ), ), ), ), - Flexible( - child: Container( - alignment: Alignment.center, - child: TextButton( - onPressed: () { - Navigator.pop(context, true); - }, - child: Text( - okText, - style: StreamChatTheme.of(context) - .textTheme - .bodyBold - .copyWith( - color: StreamChatTheme.of(context) - .colorTheme - .accentRed), - ), - ), - ), - ), - ], - ), - ], - ), - ); - }); + ], + ), + ], + ), + ); + }); /// Shows info dialog Future showInfoDialog( @@ -118,16 +119,17 @@ Future showInfoDialog( Widget? icon, String? details, StreamChatThemeData? theme, -}) => showModalBottomSheet( - backgroundColor: - theme?.colorTheme.white ?? StreamChatTheme.of(context).colorTheme.white, - context: context, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(16), - topRight: Radius.circular(16), - )), - builder: (context) => SafeArea( +}) => + showModalBottomSheet( + backgroundColor: theme?.colorTheme.white ?? + StreamChatTheme.of(context).colorTheme.white, + context: context, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + )), + builder: (context) => SafeArea( child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -173,7 +175,7 @@ Future showInfoDialog( ], ), ), - ); + ); /// Get random png with initials String getRandomPicUrl(User user) => @@ -338,16 +340,17 @@ Widget wrapAttachmentWidget( // ignore: avoid_positional_boolean_parameters bool reverse, BorderRadius borderRadius, -) => ClipRRect( - borderRadius: borderRadius, - child: Material( - clipBehavior: Clip.antiAlias, - shape: attachmentShape, - type: MaterialType.transparency, - child: Transform( - transform: Matrix4.rotationY(reverse ? pi : 0), - alignment: Alignment.center, - child: attachmentWidget, +) => + ClipRRect( + borderRadius: borderRadius, + child: Material( + clipBehavior: Clip.antiAlias, + shape: attachmentShape, + type: MaterialType.transparency, + child: Transform( + transform: Matrix4.rotationY(reverse ? pi : 0), + alignment: Alignment.center, + child: attachmentWidget, + ), ), - ), - ); + ); diff --git a/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart b/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart index cd321ca2..8cafbbff 100644 --- a/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart +++ b/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart @@ -4,10 +4,9 @@ import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:video_thumbnail/video_thumbnail.dart'; +import 'package:stream_chat_flutter/src/video_service.dart'; -import 'stream_svg_icon.dart'; -import 'video_service.dart'; - +/// Widget for creating video thumbnail image class VideoThumbnailImage extends StatefulWidget { /// Constructor for creating [VideoThumbnailImage] const VideoThumbnailImage({ @@ -38,6 +37,8 @@ class VideoThumbnailImage extends StatefulWidget { /// Builds widget on error final Widget Function(BuildContext, Object?)? errorBuilder; + + /// Builds placeholder final WidgetBuilder? placeholderBuilder; @override @@ -69,8 +70,8 @@ class _VideoThumbnailImageState extends State { @override Widget build(BuildContext context) => FutureBuilder( - future: thumbnailFuture, - builder: (context, snapshot) => AnimatedSwitcher( + future: thumbnailFuture, + builder: (context, snapshot) => AnimatedSwitcher( duration: const Duration(milliseconds: 350), child: Builder( key: ValueKey>(snapshot), @@ -108,5 +109,5 @@ class _VideoThumbnailImageState extends State { }, ), ), - ); + ); }