-
-
Notifications
You must be signed in to change notification settings - Fork 527
Open
Labels
bugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested
Description
Describe the bug
When using a provider with a record type (e.g. typedef ExampleRecord = ({String name});), the provider is not found when compiling to WASM.
To Reproduce
- Create a new Flutter project with web support.
- Run
flutter pub add provider - Replace
main.dartwith the following:
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
typedef Record = ({String name});
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return Provider<Record>.value(
value: (name: 'Hello, World!'),
child: const MaterialApp(
home: MyHomePage(),
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
print('build 0');
final record = context.read<Record>();
print('build 1');
return Scaffold(
body: Center(
child: Text(record.name),
),
);
}
}
- Run
flutter run -d chrome --wasmto run the app on Chrome using WASM. - Note that the page cannot be built, and
build 0is printed to the console butbuild 1is not. - Note that running the project with the exact same code works on web (e.g.
flutter run -d chrome) as well as on Android and iOS but not on WASM.
Expected behavior
I expected the provider to be found just like it is on CanvasKit, Android, iOS, etc.
Not sure if this is a bug within just Provider, or it's something deeper related to the Flutter framework itself.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested