问题
I was creating a Flutter application which parses a simple JSON, and it works well but gives an error in Debug Console in VS Code,
My simple JSON file:

With Lightest Code snippet :
import 'package:flutter/material.dart';
import 'dart:convert';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(title: "J2", home: new Homepage());
}
}
class Homepage extends StatefulWidget {
@override
State createState() => new HomepageState();
}
class HomepageState extends State<Homepage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text("J2")),
body: new Container(
child: new FutureBuilder(
future: DefaultAssetBundle.of(context)
.loadString('assets/data.json'),
builder: (context, snapshot) {
Map<String, dynamic> mydata =
json.decode(snapshot.data.toString());
return new Container(child: new Text(mydata['city']));
})));
}
}
And it works well but with this error in the debug console, how can I overcome it? I am a beginner.

来源:https://stackoverflow.com/questions/64841541/error-the-method-was-called-on-null-in-flutter-while-parsing-json