Repository navigation
Description
Steps to reproduce
- Show a
VectorGraphic(or aflutter_svgSvgPicture) whoseBytesLoader.loadBytesreturns a future that completes with an error — for example anSvgPicture.asseton web whose asset fetch fails because the network dropped. - Optionally give it an
errorBuilder.
Expected results
The error is handled: _loadAssetBytes catches it and the widget shows errorBuilder (or nothing).
Actual results
The widget does catch it and shows errorBuilder, but the same error is also delivered to the zone as an unhandled error — PlatformDispatcher.onError / runZonedGuarded, so crash reporters record it as fatal.
The cause is in _VectorGraphicWidgetState._loadPicture (packages/vector_graphics/lib/src/vector_graphics.dart):
_pendingPictures[key] = result;
result.whenComplete(() {
_pendingPictures.remove(key);
});
return result;whenComplete returns a new future that completes with result's error, and nothing listens to it, so it is reported as unhandled even though result itself is awaited inside a try/catch.
The existing test VectorGraphicsWidget can handle errors from bytes loader doesn't catch this because its ThrowingBytesLoader.loadBytes throws synchronously, before whenComplete is reached. Making loadBytes async reproduces it: the test fails with the UnimplementedError reported by the test framework.
Code sample
class AsyncThrowingBytesLoader extends BytesLoader {
const AsyncThrowingBytesLoader();
@override
Future<ByteData> loadBytes(BuildContext? context) async {
throw UnimplementedError('Test exception');
}
}
testWidgets('handles an asynchronous error from bytes loader', (WidgetTester tester) async {
await tester.pumpWidget(
VectorGraphic(
loader: const AsyncThrowingBytesLoader(),
width: 100,
height: 100,
errorBuilder: (BuildContext context, Object error, StackTrace stackTrace) {
return const Directionality(
textDirection: TextDirection.ltr,
child: Text('Error is handled'),
);
},
),
);
await tester.pumpAndSettle();
expect(find.text('Error is handled'), findsOneWidget);
expect(tester.takeException(), isNull); // fails: the error also escapes as unhandled
});Logs
In production (Flutter web, wasm), reported through runZonedGuarded with no caller frames after the async gap:
FlutterError: Unable to load asset: "assets/images/sign_in_logo.svg".
load flutter/packages/flutter/lib/src/services/asset_bundle.dart:332:13
_rootRunUnary dart-sdk/lib/async/zone_root.dart
...
Flutter Doctor output
Flutter 3.47.7 (stable), vector_graphics 1.2.3 (also present on main), flutter_svg 2.3.0.
Activity
suryaKommana2662 commentedon Oct 19, 2026
@mtallenca Thanks for the report. Reproduced a test failure in the
vector_graphicspackage test suite. The asynchronous loader error is reported during VectorGraphic initialization. routing to the team-engine for further investigationFlutter Doctor Output
[vector_graphics] Don't report a handled loading error as unhandled (f…
github-actions commentedon Nov 2, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.