flutter_eval icon indicating copy to clipboard operation
flutter_eval copied to clipboard

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

Open heathscliff334 opened this issue 9 months ago • 1 comments

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

heathscliff334 avatar May 16 '24 10:05 heathscliff334