-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Closed
Copy link
Labels
a: assetsPackaging, accessing, or using assetsPackaging, accessing, or using assetsa: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
As a maintainer of a flutter package that may contain references to assets, it is required that inside this package, assets should be loaded with package/<packageName> prefix in its key.
When testing code that loads these assets, we get an error after flutter 3.3.0
Steps to Reproduce
Added a simple code here in the issue and a more complete example here.
- Checkout into flutter 3.0.0
- Execute
flutter teston the code sample or on the example package. - It will pass (as it should).
- Checkout into flutter 3.3.0
- Execute
flutter teston the code sample or on the example package. - It will fail because it cant load the asset.
Expected results:
Tests should pass.
It should be consistent across versions since it was not listed as a breaking change.
Testing widgets with assets in packages can be a real hack if it is not possible to maintain the prefix during tests.
Actual results:
Tests fail.
Code sample
// Package content file: lib/src/anything.dart
import 'package:flutter/widgets.dart';
/// Some Widget with an image
class SomeImageWidget extends StatelessWidget {
/// Some Widget with an image
const SomeImageWidget({super.key});
@override
Widget build(BuildContext context) {
return Image.asset('packages/asset_bundle_bug/assets/pudim.jpg');
}
}
// Test file: test/anything_test.dart
void main() {
group('SomeImageWidget', () {
testWidgets('can be pumped', (tester) async {
await tester.pumpWidget(SomeImageWidget());
await tester.pumpAndSettle();
expect(true, true);
});
});
}
Possible context
This PR may have introduced the bug:
flutter/engine#32999
#103496
felangel, rydmike, Jordan-Nelson, nicholasspencer and pstromberg98
Metadata
Metadata
Assignees
Labels
a: assetsPackaging, accessing, or using assetsPackaging, accessing, or using assetsa: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version