Hive: Error generate file.g.dart

Created on 27 Apr 2020  路  1Comment  路  Source: hivedb/hive

Steps to Reproduce
When run $ flutter pub run build_runner build in project with hive, not generate the file.g.dart file

[INFO] Generating build script...
[INFO] Generating build script completed, took 626ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 141ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 1.5s

[INFO] Running build...
[INFO] 1.4s elapsed, 0/2 actions completed.
[INFO] 3.0s elapsed, 0/2 actions completed.
[WARNING] hive_generator:hive_generator on lib/src/models/company.model.dart:
Missing "part 'company.model.g.dart';".
[WARNING] hive_generator:hive_generator on lib/src/models/user.model.dart:
Missing "part 'user.model.g.dart';".
[INFO] Running build completed, took 3.0s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 59ms

[INFO] Succeeded after 3.1s with 0 outputs (2 actions)

Class User

import 'package:hive/hive.dart';
part 'user.g.dart';

@HiveType(typeId: 0)
class User extends HiveObject {
  @HiveField(0)
  String name;

  @HiveField(1)
  String phone;

  @HiveField(2)
  String street;

  @HiveField(3)
  String subStreet;

  @HiveField(4)
  String city;

  @HiveField(5)
  String state;

  @HiveField(6)
  String country;

  @HiveField(7)
  String latitude;

  @HiveField(8)
  String longitude;

  User(
      {this.name,
      this.phone,
      this.street,
      this.subStreet,
      this.city,
      this.state,
      this.country,
      this.latitude,
      this.longitude});
} 

Class Company

import 'package:hive/hive.dart';
part 'company.g.dart';

@HiveType(typeId: 1)
class Company extends HiveObject {
  @HiveField(0)
  String name;
}


Version

  • Platform: Mac OS X 10.13.6 17G11023
  • Flutter version: v1.12.13+hotfix.9
  • Hive version: hive: ^1.4.1+1
    hive_flutter: ^0.3.0+2
    hive_generator: ^0.7.0+2
    build_runner: ^1.9.0
problem

Most helpful comment

I found the solution myself.
My files were called user.model.dart and company.model.dart
I changed them to user.dart and company.dart and ready, problem solved

>All comments

I found the solution myself.
My files were called user.model.dart and company.model.dart
I changed them to user.dart and company.dart and ready, problem solved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rupamking1 picture rupamking1  路  3Comments

aminjoharinia picture aminjoharinia  路  3Comments

jamesdixon picture jamesdixon  路  3Comments

Hopheylalal picture Hopheylalal  路  4Comments

kthecoder picture kthecoder  路  3Comments