0
ダーツのファイルからJSONを解析しようとしています。私はファイルを読み込んで印刷しましたが、JSONに変換しようとすると、スローされエラーが発生します。JSON.decodeのダーツのNosuchMethod
file.dart:
import 'dart:convert' as JSON;
import 'dart:io';
main() {
final jsonAsString = new File('./text.json').readAsString().then(print); //Successful printing of json
final json = JSON.decode(jsonAsString);
print('$json');
}
エラー:私はここで何を
Unhandled exception:
NoSuchMethodError: No top-level method 'JSON.decode' declared.
Receiver: top-level
Tried calling: JSON.decode(Instance of '_Future')
#0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:196)
#1 main (file:///Users/ninanjohn/Trials/dartTrials/stubVerifier.dart:7:15)
#2 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
#3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
を見つからないか、間違っているのでしょうか?