Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing part 'Appdatabase.g.dart' flutter in FLOOR database

I followed the flutter floor tutorial , Here is my database file

import 'package:floor/floor.dart';
import 'package:news_app/database/daos/Userdao.dart';
import 'package:news_app/database/entities/User.dart';
part "AppDatabase.g.dart";


@Database(entities: [User], version: 1)
abstract class ApplicationDatabase extends FloorDatabase {
  Userdao get userDao;
}

Here is my dao file,

import 'package:floor/floor.dart';
import 'package:news_app/database/entities/User.dart';

@dao
abstract class Userdao{

  @Query("select * from table_user")
  Future<List<User>> getUsersList();

  @insert
  Future<void> insertUser(User user);

}

Here is my entity file,

import 'package:floor/floor.dart';

@Entity(tableName: 'table_user')
class User{

  @PrimaryKey(autoGenerate: true)
  int id;

  String name;

  String password;

  User({this.id,this.name,this.password});

}


dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  fluttertoast: 3.1.3
  shared_preferences: 0.5.6
  retrofit: any
  logger: any
  dio: 3.0.8
  http: 0.12.0+4
  json_serializable: any
  floor: ^0.9.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  retrofit_generator: any
  build_runner: any
  floor_generator: ^0.9.0

Whenever I try to run this command flutter pub run build_runner build command I get this error

[INFO] Running build... [INFO] 1.7s elapsed, 0/1 actions completed. [WARNING] floor_generator:floor_generator on lib/database/ApplicationDatabase.dart: Missing "part 'ApplicationDatabase.g.dart';".

like image 460
Balaji Avatar asked Oct 18 '25 20:10

Balaji


1 Answers

Are you using the same names of file for database

like appdatabase.dart and appdatabase.g.dart

like image 62
Mhamza007 Avatar answered Oct 20 '25 10:10

Mhamza007