Generating *.g.dart files

When creating model classes needed to decode JSON retrieved from network request in Flutter, part of the code is generated and placed in *.g.dart file. It contains methods FromJson and ToJson that allows easy deserialization and serialization. To generate this file, following command must be run from Terminal tab in Visual Studio Code.

flutter pub run build_runner build

Leave a Reply

Your email address will not be published. Required fields are marked *