diff --git a/example/lib/new_chat_screen.dart b/example/lib/new_chat_screen.dart index df4b7c3c..aeb4298e 100644 --- a/example/lib/new_chat_screen.dart +++ b/example/lib/new_chat_screen.dart @@ -193,9 +193,13 @@ class _NewChatScreenState extends State { child: Row( children: [ StreamNeumorphicButton( - child: StreamSvgIcon( - assetName: 'Icon_contacts.svg', - color: Color(0xFF006CFF), + child: Center( + child: StreamSvgIcon( + assetName: 'Icon_contacts.svg', + color: Color(0xFF006CFF), + height: 24, + width: 24, + ), ), ), SizedBox(width: 8), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index bc892255..7cd6045a 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 1.0.68+70 +version: 1.0.69+71 environment: sdk: ">=2.2.2 <3.0.0" diff --git a/lib/src/stream_svg_icon.dart b/lib/src/stream_svg_icon.dart index 25571150..c0cf5d72 100644 --- a/lib/src/stream_svg_icon.dart +++ b/lib/src/stream_svg_icon.dart @@ -9,20 +9,21 @@ class StreamSvgIcon extends StatelessWidget { final Color color; const StreamSvgIcon({ - Key key, this.assetName, this.width, this.height, this.color, - }) : super(key: key); + }); @override Widget build(BuildContext context) { + final key = Key('StreamSvgIcon-$assetName'); return kIsWeb ? Image.network( 'packages/stream_chat_flutter/svgs/$assetName', width: width, height: height, + key: key, color: color, fit: BoxFit.cover, alignment: Alignment.center, @@ -30,6 +31,7 @@ class StreamSvgIcon extends StatelessWidget { : SvgPicture.asset( 'lib/svgs/$assetName', package: 'stream_chat_flutter', + key: key, width: width, height: height, fit: BoxFit.cover, diff --git a/test/src/message_reaction_modal_test.dart b/test/src/message_reaction_modal_test.dart index 622b57c3..d1c2a49c 100644 --- a/test/src/message_reaction_modal_test.dart +++ b/test/src/message_reaction_modal_test.dart @@ -42,7 +42,8 @@ void main() { await tester.pump(Duration(milliseconds: 1000)); expect(find.byKey(Key('MessageWidget')), findsOneWidget); - expect(find.byIcon(StreamIcons.thumbs_up_reaction), findsOneWidget); + expect(find.byKey(Key('StreamSvgIcon-Icon_thumbs_up_reaction.svg')), + findsOneWidget); }, ); @@ -91,8 +92,10 @@ void main() { await tester.pump(Duration(milliseconds: 1000)); expect(find.byKey(Key('MessageWidget')), findsOneWidget); - expect(find.byIcon(StreamIcons.thumbs_up_reaction), findsNWidgets(2)); - expect(find.byIcon(StreamIcons.love_reaction), findsNWidgets(2)); + expect(find.byKey(Key('StreamSvgIcon-Icon_thumbs_up_reaction.svg')), + findsNWidgets(2)); + expect(find.byKey(Key('StreamSvgIcon-Icon_love_reaction.svg')), + findsNWidgets(2)); expect(find.text(testUserId), findsNWidgets(2)); }, ); diff --git a/test/src/reaction_bubble_test.dart b/test/src/reaction_bubble_test.dart index c524061c..6518dc94 100644 --- a/test/src/reaction_bubble_test.dart +++ b/test/src/reaction_bubble_test.dart @@ -25,7 +25,8 @@ void main() { ), ); - expect(find.byIcon(StreamIcons.thumbs_up_reaction), findsNothing); + expect(find.byKey(Key('StreamSvgIcon-Icon_thumbs_up_reaction.svg')), + findsNothing); }, ); @@ -61,7 +62,8 @@ void main() { ), ); - expect(find.byIcon(StreamIcons.thumbs_up_reaction), findsOneWidget); + expect(find.byKey(Key('StreamSvgIcon-Icon_thumbs_up_reaction.svg')), + findsOneWidget); }, ); testWidgets( @@ -100,8 +102,10 @@ void main() { ), ); - expect(find.byIcon(StreamIcons.thumbs_up_reaction), findsOneWidget); - expect(find.byIcon(StreamIcons.love_reaction), findsOneWidget); + expect(find.byKey(Key('StreamSvgIcon-Icon_thumbs_up_reaction.svg')), + findsOneWidget); + expect(find.byKey(Key('StreamSvgIcon-Icon_love_reaction.svg')), + findsOneWidget); }, ); }