Flutter parses local json

Create two directories assets at the same level as lib to place json files in them


Configured in pubspec.yaml, after configuring this, it means that the files in assets can be accessed

Instructions:

      rootBundle.loadString("images/list.json").then((value){
         BaseEntity.fromJson(json.decode(value) , (json) {
           //数据
          print("hzq--->json" +json.toString() );
        });
      });

 

Guess you like

Origin blog.csdn.net/hzqit520/article/details/122062320