ethanblake4 / flutter_eval

Code push for Flutter, powered by dart_eval

Home Page:https://pub.dev/packages/flutter_eval

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CompileError: Could not find declaration "runApp" on flutter 3.3.0

zmtzawqlp opened this issue · comments

i am follow the readme, add flutter_eval.json into project and run dart_eval compile -o program.evc, get some error, would you please check it if you have time, thanks.

demo.zip

CompileError: Could not find declaration "runApp"
#0      IdentifierReference.getValue (package:dart_eval/src/eval/compiler/reference.dart:199:57)
#1      compileIdentifier (package:dart_eval/src/eval/compiler/expression/identifier.dart:13:48)
#2      compileMethodInvocation (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:30:20)
#3      compileExpression (package:dart_eval/src/eval/compiler/expression/expression.dart:28:12)
#4      compileExpressionAndDiscardResult (package:dart_eval/src/eval/compiler/expression/expression.dart:76:5)
#5      compileStatement (package:dart_eval/src/eval/compiler/statement/statement.dart:21:5)
#6      compileBlock (package:dart_eval/src/eval/compiler/statement/block.dart:16:20)
#7      compileFunctionDeclaration (package:dart_eval/src/eval/compiler/declaration/function.dart:50:14)
#8      compileDeclaration (package:dart_eval/src/eval/compiler/declaration/declaration.dart:20:5)
#9      Compiler.compileSources.<anonymous closure>.<anonymous closure> (package:dart_eval/src/eval/compiler/compiler.dart:301:9)
#10     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:617:13)
#11     Compiler.compileSources.<anonymous closure> (package:dart_eval/src/eval/compiler/compiler.dart:290:13)
#12     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:617:13)
#13     Compiler.compileSources (package:dart_eval/src/eval/compiler/compiler.dart:287:30)
#14     Compiler.compile (package:dart_eval/src/eval/compiler/compiler.dart:117:12)
#15     main (file:///Users/zmt/.pub-cache/hosted/pub.flutter-io.cn/dart_eval-0.4.5/bin/dart_eval.dart:103:36)
#16     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#17     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
commented

Hi, flutter_eval does not support runApp. That's because you are supposed to use it inside of an existing Flutter app, which is already calling runApp. So, you can just comment out the runApp part, or even the entire main function. Instead of calling main in EvalWidget, you should specify a widget constructor, like "MyApp." (don't forget the .)

u should specify a widget constructo

thanks for quick reply, it's better to add those comments to readme, and give the user a full successful steps. thanks

commented

Added documentation to readme in ccb607e. Closing

still has some error. after i change as readme said:

Widget main() {
  // do any setup, then
  return MyApp();
}
// void main() {
//   //runApp(const MyApp());
// }

dart_eval: 0.4.7

Unhandled exception:
Null check operator used on a null value
#0      _resolveImportsAndExports.<anonymous closure> (package:dart_eval/src/eval/compiler/compiler.dart:620:87)
#1      MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#2      ListIterable.toSet (dart:_internal/iterable.dart:218:18)
#3      _resolveImportsAndExports (package:dart_eval/src/eval/compiler/compiler.dart:620:90)
#4      Compiler.compileSources (package:dart_eval/src/eval/compiler/compiler.dart:165:9)
#5      Compiler.compile (package:dart_eval/src/eval/compiler/compiler.dart:118:12)
#6      main (file:///Users/zmtzawqlp/Documents/github/hot_update/flutter_eval/dart_eval/bin/dart_eval.dart:103:36)
#7      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#8      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)