Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Records not supported on WASM #890

Open
putnokiabel opened this issue Sep 20, 2024 · 3 comments
Open

Records not supported on WASM #890

putnokiabel opened this issue Sep 20, 2024 · 3 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@putnokiabel
Copy link

putnokiabel commented Sep 20, 2024

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.

@rrousselGit
Copy link
Owner

That's most definitely an SDK issue, not a provider bug.

@rrousselGit rrousselGit added question Further information is requested and removed needs triage labels Sep 20, 2024
@putnokiabel
Copy link
Author

Thank you @rrousselGit !
In that case, could you help me submit an issue for this on https://github.com/flutter/flutter , or help construct a code example without the use of Provider?
Unfortunately I'm not sure how this example would translate to the underlying APIs of the Flutter SDK.

@rrousselGit
Copy link
Owner

I don't really have the time for this, sorry.

I'd suggest trying to keep your example as is. It's probably small enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants