ethanblake4 / dart_eval

Extensible Dart interpreter for Dart with full interop
https://pub.dev/packages/dart_eval
BSD 3-Clause "New" or "Revised" License
334 stars 40 forks source link

Could not find declaration "File" at unknown (file package:example/main.dart) #188

Closed cattlelovegrass closed 9 months ago

cattlelovegrass commented 9 months ago

File("asset/3.0x/battery_box_bg.png");

ethanblake4 commented 9 months ago

Did you import dart:io?

cattlelovegrass commented 9 months ago

Did you import dart:io?

YES, this library is Imported

cattlelovegrass commented 9 months ago

Error: dart_eval runtime exception: RangeError (index): Index out of range: no indices are valid: 0 dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 294:3 throw dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart 600:7 _get] packages/dart_eval/src/eval/shared/stdlib/io/file.dart 276:32 $new dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 294:3 throw packages/dart_eval/src/eval/runtime/runtime.dart 832:7 execute packages/dart_eval/src/eval/runtime/runtime.dart 810:12 executeLib packages/example/main.dart 146:10

cattlelovegrass commented 9 months ago

I add breakpoint, It throws error: static $File $new(Runtime runtime, $Value? target, List<$Value?> args) { return $File.wrap(File(args[0]!.$value)); } List<$Value?> args IS Empty, the console shows args size is 0

ethanblake4 commented 9 months ago

Yes ok I will fix that. You cannot use File when compiling to Web / JS platform though.

cattlelovegrass commented 9 months ago

Yes ok I will fix that. You cannot use File when compiling to Web / JS platform though.

constructors: { '': BridgeConstructorDef(BridgeFunctionDef( returns: BridgeTypeAnnotation($type), params: [ BridgeParameter('path', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), ], namedParams: [])) }, You just add path to Constructor params, then args[0] is not empty,

cattlelovegrass commented 9 months ago

closed

ethanblake4 commented 8 months ago

This fix is now released in version 0.7.7