Add this to your package's pubspec.yaml file:
You can then install packages from the command line:
Alternatively, your editor might support dart pub get
. Check the docs for your editor to learn more.
Now you can use it in your Dart code by importing it like this:
Note that the line partmy_demo.g.dart
will give you a warning, because the file is not created yet
Write the following code
To generate the code type the following command
It is likely that the code generated by Json_Serializer will cause your linter to report warnings.
The solution to this problem is to tell the linter to ignore generated files, by modifying your analysis_options.yaml
: