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

webassembly bug #975

Open
ArturLevchuk opened this issue Nov 2, 2024 · 7 comments · May be fixed by #982
Open

webassembly bug #975

ArturLevchuk opened this issue Nov 2, 2024 · 7 comments · May be fixed by #982
Labels
new New issue request attention

Comments

@ArturLevchuk
Copy link

Describe the bug
Looks like problem with auto-injector for wasm. In general web all is ok.

Environment
Flutter 3.24.4
flutter_modular: 6.3.4

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),
      ),
    );
  }
}

Screenshots
image

@ArturLevchuk ArturLevchuk added the new New issue request attention label Nov 2, 2024
@joaovvrodrigues
Copy link

joaovvrodrigues commented Nov 14, 2024

@jacobaraujo7 @davidsdearaujo, Could you please check this issue with the Modular using Auto Injector?

In my company, we use Modular extensively with Flutter Web, and it's preventing us from utilizing the new Flutter features.

davidsdearaujo added a commit to davidsdearaujo/auto_injector that referenced this issue Dec 12, 2024
…ion method and enhance class name extraction logic

- Updated the parameter addition method to insert positional parameters at the beginning of the list.
- Improved class name extraction from constructor strings using regex, with error handling for unmatched cases.
- Removed generics from the extracted class name for cleaner output.
@davidsdearaujo
Copy link
Member

davidsdearaujo commented Dec 12, 2024

@joaovvrodrigues thank you for reporting this bug.
I guess I fixed that on auto_injector in this branch, could you try to override your auto_injector dependency?

Add this to the end of your pubspec.yaml:

dependency_overrides:
  auto_injector:
    git:
      url: https://github.com/davidsdearaujo/auto_injector
      ref: issue-975-webassembly-bug

@joaovvrodrigues
Copy link

Hi @davidsdearaujo, thanks for your feedback. Apparently the problem still persists.

Captura de Tela 2024-12-12 às 13 32 30

@davidsdearaujo
Copy link
Member

@joaovvrodrigues Could you describe what steps are you following to run the project in wasm?

@joaovvrodrigues
Copy link

joaovvrodrigues commented Dec 20, 2024

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

https://docs.flutter.dev/platform-integration/web/wasm

@HudsonAfonso
Copy link

+1

davidsdearaujo added a commit to davidsdearaujo/modular that referenced this issue Jan 2, 2025
@davidsdearaujo davidsdearaujo linked a pull request Jan 2, 2025 that will close this issue
7 tasks
davidsdearaujo added a commit to davidsdearaujo/modular that referenced this issue Jan 2, 2025
Change named params to positional params in order to work with wasm
@davidsdearaujo
Copy link
Member

davidsdearaujo commented Jan 2, 2025

@ArturLevchuk @joaovvrodrigues @HudsonAfonso Please try to override the flutter_modular dependency like that:

dependency_overrides:
  flutter_modular:
    git:
      url: https://github.com/davidsdearaujo/modular.git
      ref: dcadc389f546680cc9b63cf3f7b5e65ded8361ae
      path: flutter_modular

This will point to this PR, please take a look at the PR description:

Drop a comment in the PR if it worked for you!

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

Successfully merging a pull request may close this issue.

4 participants