flutter_svg_test

Last updated:

0 purchases

flutter_svg_test Image
flutter_svg_test Images
Add to Cart

Description:

flutter svg test

flutter_svg_test #
Testing #
This package provides a set of functions to find images generated by
flutter_svg
in widget tests.
The methods find elements with the SvgPicture type and compare either the BytesLoader or the
configuration of the BytesLoader with the giving test attribute.
Example #
Find by BytesLoader
The following example shows how you can find svgs with the matching SvgAssetLoader.
testWidgets('Finds svg', (WidgetTester widgetTester) async {

final SvgPicture asset = SvgPicture.asset('/test/path/my.svg');

await widgetTester.pumpWidget(asset);

expect(find.svg(asset.bytesLoader), findsOneWidget);
});
copied to clipboard
Find by svg path
Sometimes it is more convenient instead of instantiate the whole BytesLoader to
compare only specific attributes.
The following example shows how you can find svgs with the specified attribute.
testWidgets('asset svg with path', (WidgetTester widgetTester) async {
const String svgPath = 'test/flutter_logo.svg';

await widgetTester.pumpWidget(SvgPicture.asset(svgPath));

expect(find.svgAssetWithPath(svgPath), findsOneWidget);
});
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.