文件最后提交记录最后更新时间
Add svg finder (#880) * Extract flutter svg to package * Add flutter svg test library * Adjust readme * Update and rename ci.yml to flutter_svg.yml * Create flutter_svg_test.yml --------- Co-authored-by: Dan Field <dfield@gmail.com>3 年前
[flutter_svg] Adopt code excerpts (#8181) Converts the README from unmanaged code examples to code excerpted from analyzed and compiled code. Part of https://github.com/flutter/flutter/issues/1026791 年前
Update repo for 3.32 stable (#9311) Does all of the steps from https://github.com/flutter/flutter/blob/master/docs/ecosystem/release/Updating-Packages-repo-for-a-stable-release.md for the 3.32 stable release (except the first one, as the stable roller has already landed).11 个月前
License for _test 2 年前
[flutter_svg] Initial import Imports https://github.com/dnfield/flutter_svg into this repository, with history, and updates it to follow repository conventions: - Updates min SDKs. - Removes analysis options and fixes resulting warnings. - Autoformats. - Updates pubspecs to follow repo standard. - Updates repo tooling to allow the flutter_svg_test non-dev dependency on flutter_test. - Adds repo metadata. - Adds METADATA files. - Adds commemoration to README. - Updates example app Android build files to current standards. - Bumps versions and slightly relax version constraints for vector_graphics* to allow the new versions. - Moves gitignore of golden test diffs into the package. 1 年前
[flutter_svg] Adopt code excerpts (#8181) Converts the README from unmanaged code examples to code excerpted from analyzed and compiled code. Part of https://github.com/flutter/flutter/issues/1026791 年前
[flutter_svg] Initial import Imports https://github.com/dnfield/flutter_svg into this repository, with history, and updates it to follow repository conventions: - Updates min SDKs. - Removes analysis options and fixes resulting warnings. - Autoformats. - Updates pubspecs to follow repo standard. - Updates repo tooling to allow the flutter_svg_test non-dev dependency on flutter_test. - Adds repo metadata. - Adds METADATA files. - Adds commemoration to README. - Updates example app Android build files to current standards. - Bumps versions and slightly relax version constraints for vector_graphics* to allow the new versions. - Moves gitignore of golden test diffs into the package. 1 年前
Update repo for 3.32 stable (#9311) Does all of the steps from https://github.com/flutter/flutter/blob/master/docs/ecosystem/release/Updating-Packages-repo-for-a-stable-release.md for the 3.32 stable release (except the first one, as the stable roller has already landed).11 个月前
README.md

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('asset svg', (WidgetTester widgetTester) async {
  final SvgPicture asset = SvgPicture.asset('test/flutter_logo.svg');
  await widgetTester.pumpWidget(
    DefaultAssetBundle(
      bundle: _FakeAssetBundle(),
      child: asset,
    ),
  );

  expect(find.svg(asset.bytesLoader), findsOneWidget);
});

Find by svg path

Sometimes it is more convenient instead of instantiating 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(
    DefaultAssetBundle(
      bundle: _FakeAssetBundle(),
      child: SvgPicture.asset(svgPath),
    ),
  );

  expect(find.svgAssetWithPath(svgPath), findsOneWidget);
});

Commemoration

This package was originally authored by Dan Field and has been forked here from dnfield/flutter_svg. Dan was a member of the Flutter team at Google from 2018 until his death in 2024. Dan’s impact and contributions to Flutter were immeasurable, and we honor his memory by continuing to publish and maintain this package.