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

[In Release Mode] Invalid argument(s): Cannot find package:example/main.dart, maybe it wasn't declared as an entrypoint? #82

Open
heathscliff334 opened this issue May 16, 2024 · 1 comment

Comments

@heathscliff334
Copy link

Hi, Thank you for this awesome package.
However, I wonder why I get this error on Release Mode but it's working well on Debug Mode

Log

Launching lib/main.dart on sdk gphone64 arm64 in release mode...
✓  Built build/app/outputs/flutter-apk/app-release.apk (8.1MB).
I/flutter (21630): Invalid argument(s): Cannot find package:flutter_code_push/lib/main.dart, maybe it wasn't declared as an entrypoint?

I'm following this example:

import 'package:flutter/material.dart';
import 'package:flutter_eval/flutter_eval.dart';
import 'package:dart_eval/dart_eval_bridge.dart';

void main() {
  runApp(const EvalExample());
}

class EvalExample extends StatelessWidget {
  const EvalExample({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {

    return const EvalWidget(
      packages: {
        'example': {
          'main.dart': '''
              import 'package:flutter/material.dart';

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

                // This widget is the root of your application.
                @override
                Widget build(BuildContext context) {
                  return MaterialApp(
                    title: 'flutter_eval demo',
                    home: const MyHomePage(title: 'Kevin '),
                  );
                }
              }

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

                final String title;

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

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

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

                @override
                Widget build(BuildContext context) {
                  return Scaffold(
                    appBar: AppBar(
                      title: Text(widget.title),
                    ),
                    body: Center(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                          const Text(
                            'XX You have pushed the button this many times:',
                          ),
                          Text(
                            '\$_counter',
                            style: Theme.of(context).textTheme.headline4,
                          ),
                        ],
                      )
                    ),
                    floatingActionButton: FloatingActionButton(
                      onPressed: _incrementCounter,
                      tooltip: 'Increment',
                      child: Icon(Icons.add),
                    ),
                  );
                }
              }

            '''
        }
      },
      assetPath: 'assets/program.evc',
      library: 'package:flutter_code_push/lib/main.dart',
      function: 'MyApp.',
      args: [null],
    );
  }
}

@wrbl606
Copy link
Contributor

wrbl606 commented Jun 2, 2024

You should use the CompilerWidget if you're not intending to provide the precompiled .evc file in the release mode. See https://pub.dev/packages/flutter_eval#quickstart-for-dynamic-execution-and-server-driven-ui for more details.

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

2 participants