Skip to content

Records not supported on WASM #890

@putnokiabel

Description

@putnokiabel

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

  1. Create a new Flutter project with web support.
  2. Run flutter pub add provider
  3. Replace main.dart with 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),
      ),
    );
  }
}
  1. Run flutter run -d chrome --wasm to run the app on Chrome using WASM.
  2. Note that the page cannot be built, and build 0 is printed to the console but build 1 is not.
  3. 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 workingquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions