Flutter built value, not generating .g file

710 views Asked by At

I am a newbie in flutter. I am building Post class using built-value. The class looks like

import 'package:built_value/built_value.dart';

part 'posts.g.dart';

abstract class Post implements Built<Post, PostBuilder> {
  Post._();
  factory Post([void Function(PostBuilder) updates]) = _$Post;
}

With pubspec.yaml file as:

dependencies:
  url_launcher: "^3.0.0"
  built_value: "^7.1.0"
  built_collection: "^4.3.2"
  flutter:
    sdk: flutter


  cupertino_icons: "^0.1.3"

dev_dependencies:
  build_runner: "^1.0.0"
  build_test: "^0.10.3"
  flutter_test:
    sdk: flutter

The posts.g.dart file is not generating on running flutter packages pub run build_runner build.

1

There are 1 answers

0
Ayush Saxena On BEST ANSWER

Change the pubspec.yaml file to:

dependencies:
  url_launcher: "^3.0.0"
  built_value: "^7.1.0"
  built_collection: "^4.3.2"
  flutter:
    sdk: flutter


  cupertino_icons: "^0.1.3"

dev_dependencies:
  build_runner: ^1.0.0
  built_value_generator: ^7.1.0
  flutter_test:
    sdk: flutter

dependency_overrides:
  analyzer: '0.39.14'