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

BUG - Support for WebAssembly (Wasm) #23

Open
joaovvrodrigues opened this issue Nov 14, 2024 · 3 comments
Open

BUG - Support for WebAssembly (Wasm) #23

joaovvrodrigues opened this issue Nov 14, 2024 · 3 comments

Comments

@joaovvrodrigues
Copy link

Describe the bug:

Flutter 3.24 or newer supports running a web app with Wasm using flutter run --wasm.

Auto-Injector for wasm.

RuntimeError: dereferencing a null pointer at ModularRouteInformationParser. This could be related to an issue when parsing routes in Flutter Web.

AutoInjector Error:
There's an error in the AutoInjectorImpl._resolveBind method, specifically when resolving an instance by class name. This might indicate an issue with dependency injection where the required instance could not be found or injected.
It seems that the core issue is within the dependency injection process (AutoInjectorImpl) and how ModularRouteInformationParser handles routing, especially on Flutter Web.

Captura de Tela 2024-11-14 às 12 27 06

Environment:
Flutter: 3.24.4
flutter_modular: ^6.3.4
auto_injector: ^2.0.5

To Reproduce

import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(ModularApp(
    module: AppModule(),
    child: const MyApp(),
  ));
}

class AppModule extends Module {
  @override
  void routes(RouteManager r) {
    r.child("/",
        child: (context) => const MyHomePage(title: 'Flutter Demo Home Page'));
  }
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      routerConfig: Modular.routerConfig,
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
@joaovvrodrigues joaovvrodrigues changed the title Support for WebAssembly (Wasm) BUG BUG - Support for WebAssembly (Wasm) Nov 14, 2024
@joaovvrodrigues
Copy link
Author

joaovvrodrigues commented Nov 14, 2024

Reported by @ArturLevchuk a more 2 weeks ago.

@HudsonAfonso
Copy link

+1

@davidsdearaujo
Copy link
Member

Working on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants