flutter_svg_test
1.0.3, released 2 years ago by flutter.dev
A testing library for finding and verifying flutter_svg images in widget tests.
What it does
Provides custom finder methods for widget tests to easily locate and verify flutter_svg elements such as SvgPicture. You can match images either by their BytesLoader or specific attributes like the SVG asset path.
AI-written summary of version 1.0.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are writing widget tests for a Flutter app that uses flutter_svg.
- You need to verify that specific SVG assets or pictures are rendered correctly in widget trees.
Skip it when
- Your project does not use flutter_svg.
- You are performing standard unit testing without widget or UI testing requirements.
Strengths
- Simplifies testing of SVG images in widget tests
- Provides convenient finders for BytesLoader and SVG paths
Weaknesses
- Limited in scope strictly to testing flutter_svg components
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
not documented
testWidgets('asset svg with path', (WidgetTester widgetTester) async {
const String svgPath = 'test/flutter_logo.svg';
await widgetTester.pumpWidget(
DefaultAssetBundle(
bundle: _FakeAssetBundle(),
child: SvgPicture.asset(svgPath),
),
);
expect(find.svgAssetWithPath(svgPath), findsOneWidget);
});Alternatives
Packages that do the same job and could replace flutter_svg_test.
- bloc_test
A testing library that makes it easy to test blocs and cubits.
82Compare - elementary_test
Testing library for apps built with the Elementary architecture.
68Compare - alchemist
Streamlined golden testing tool for Flutter with local and CI-safe output support
94Compare - patrol_log
Log package for Patrol, a Flutter-native UI testing framework
87Compare
Works with
Packages commonly used together with flutter_svg_test: ones it builds on, ones built on it, and its own family.