floor icon indicating copy to clipboard operation
floor copied to clipboard

Cann't create code, already checked issues but they couldn't help

Open flogeiger opened this issue 3 years ago • 3 comments

first class:

@Entity(tableName: 'fav_table') class FavoriteRecip { @PrimaryKey(autoGenerate: true) @ColumnInfo(name: "recipe_id") int id;

@ColumnInfo(name: "recipe_Name") String recipeName;

@ColumnInfo(name: "description") String description;

@ColumnInfo(name: "recipeTyp") String recipeTyp;

@ColumnInfo(name: "picUrl") String picUrl;

@ColumnInfo(name: "duration") int duration;

@ColumnInfo(name: "kilocal") int kilocal;

@ColumnInfo(name: "recipe_preparation") String preparationList;

@ColumnInfo(name: "recipe_ingredients") String ingredientslist;

@ColumnInfo(name: "Time_Recipe_save") String savingTimerecipe;

FavoriteRecip( {this.id, this.recipeName, this.description, this.picUrl, this.ingredientslist, this.preparationList, this.kilocal, this.duration, this.recipeTyp, this.savingTimerecipe}); }

seccond Class:

@Entity(tableName: 'steps_table') class StepData { @PrimaryKey(autoGenerate: true) @ColumnInfo(name: "step_id") int id;

@ColumnInfo(name: "count of steps") int steps;

@ColumnInfo(name: "distance") double distance;

@ColumnInfo(name: "Date_of_Walking") String stepDate;

@ColumnInfo(name: "Walking_time") String time;

StepData({ this.id, this.steps, this.distance, this.stepDate, this.time, }); }

Daos:

@dao abstract class Fav_dao { @Query('SELECT * FROM fav_table') Future<List<FavoriteRecip>> getAllEntrysfromTable();

@delete Future deleteRecipe(FavoriteRecip recip);

@Insert(onConflict: OnConflictStrategy.rollback) Future insertRecipe(FavoriteRecip recip); } @dao abstract class Step_dao { @Query('SELECT * from steps_table') Future<List> getAllentrysfromtable(); }

Where I create the Database:

part 'Database.g.dart';

@Database(version: 1, entities: [StepData, FavoriteRecip]) abstract class CostumeDatabase extends FloorDatabase { Step_dao get stepsdao;

Fav_dao get favoriteRecipedao; }

What I get from the Console:

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

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

[INFO] Checking for updates since last build... [INFO] Checking for updates since last build completed, took 889ms

[INFO] Running build... [INFO] 1.2s elapsed, 0/3 actions completed. [INFO] 2.2s elapsed, 0/3 actions completed. [INFO] 4.1s elapsed, 0/3 actions completed. [INFO] 7.4s elapsed, 0/3 actions completed. [SEVERE] floor_generator:floor_generator on lib/Database/Database.dart: An error FormatterException occurred while formatting the generated source for package:sample/Database/Database.dart which was output to lib/Database/Database.floor.g.part. This may indicate an issue in the generator, the input source code, or in the source formatter. Could not format because the source could not be parsed:

line 101, column 11 of .: Methods must have an explicit list of parameters. ╷ 101 │ @override Future<List<FavoriteRecip*>> getAllEntrysfromTable() async { return _queryAdapter.queryList('SELECT * FROM fav_table', mapper: (Map<String, Object?> row) => FavoriteRecip(id: row['recipe_id'] as int*, recipeName: row['recipe_Name'] as String*, description: row['description'] as String*, picUrl: row['picUrl'] as String*, ingredientslist: row['recipe_ingredients'] as String*, preparationList: row['recipe_preparation'] as String*, kilocal: row['kilocal'] as int*, duration: row['duration'] as int*, recipeTyp: row['recipeTyp'] as String*, savingTimerecipe: row['Time_Recipe_save'] as String*)); } │ ^^^^^^ ╵ line 87, column 37 of .: A function body must be provided. ╷ 87 │ @override Future<List<StepData*>> getAllentrysfromtable() async { return _queryAdapter.queryList('SELECT * from steps_table', mapper: (Map<String, Object?> row) => StepData(id: row['step_id'] as int*, steps: row['count of steps'] as int*, distance: row['distance'] as double*, stepDate: row['Date_of_Walking'] as String*, time: row['Walking_time'] as String*)); } │ ^^^^^^^^^^^^^^^^^^^^^ ╵ line 87, column 35 of .: A function body must be provided. ╷ 87 │ @override Future<List<StepData*>> getAllentrysfromtable() async { return _queryAdapter.queryList('SELECT * from steps_table', mapper: (Map<String, Object?> row) => StepData(id: row['step_id'] as int*, steps: row['count of steps'] as int*, distance: row['distance'] as double*, stepDate: row['Date_of_Walking'] as String*, time: row['Walking_time'] as String*)); } │ ^ ╵ line 101, column 40 of .: Operator declarations must be preceded by the keyword 'operator'. ╷ 101 │ @override Future<List<FavoriteRecip*>> getAllEntrysfromTable() async { return _queryAdapter.queryList('SELECT * FROM fav_table', mapper: (Map<String, Object?> row) => FavoriteRecip(id: row['recipe_id'] as int*, recipeName: row['recipe_Name'] as String*, description: row['description'] as String*, picUrl: row['picUrl'] as String*, ingredientslist: row['recipe_ingredients'] as String*, preparationList: row['recipe_preparation'] as String*, kilocal: row['kilocal'] as int*, duration: row['duration'] as int*, recipeTyp: row['recipeTyp'] as String*, savingTimerecipe: row['Time_Recipe_save'] as String*)); } │ ^ ╵ line 101, column 40 of .: Methods must have an explicit list of parameters. ╷ 101 │ @override Future<List<FavoriteRecip*>> getAllEntrysfromTable() async { return _queryAdapter.queryList('SELECT * FROM fav_table', mapper: (Map<String, Object?> row) => FavoriteRecip(id: row['recipe_id'] as int*, recipeName: row['recipe_Name'] as String*, description: row['description'] as String*, picUrl: row['picUrl'] as String*, ingredientslist: row['recipe_ingredients'] as String*, preparationList: row['recipe_preparation'] as String*, kilocal: row['kilocal'] as int*, duration: row['duration'] as int*, recipeTyp: row['recipeTyp'] as String*, savingTimerecipe: row['Time_Recipe_save'] as String*)); } │ ^ ╵ line 101, column 40 of .: A function body must be provided. ╷ 101 │ @override Future<List<FavoriteRecip*>> getAllEntrysfromTable() async { return _queryAdapter.queryList('SELECT * FROM fav_table', mapper: (Map<String, Object?> row) => FavoriteRecip(id: row['recipe_id'] as int*, recipeName: row['recipe_Name'] as String*, description: row['description'] as String*, picUrl: row['picUrl'] as String*, ingredientslist: row['recipe_ingredients'] as String*, preparationList: row['recipe_preparation'] as String*, kilocal: row['kilocal'] as int*, duration: row['duration'] as int*, recipeTyp: row['recipeTyp'] as String*, savingTimerecipe: row['Time_Recipe_save'] as String*)); } │ ^ ╵ line 87, column 202 of .: Expected to find ')'. ╷ 87 │ @override Future<List<StepData*>> getAllentrysfromtable() async { return _queryAdapter.queryList('SELECT * from steps_table', mapper: (Map<String, Object?> row) => StepData(id: row['step_id'] as int*, steps: row['count of steps'] as int*, distance: row['distance'] as double*, stepDate: row['Date_of_Walking'] as String*, time: row['Walking_time'] as String*)); } │ ^ ╵ line 87, column 11 of .: Methods must have an explicit list of parameters. ╷ 87 │ @override Future<List<StepData*>> getAllentrysfromtable() async { return _queryAdapter.queryList('SELECT * from steps_table', mapper: (Map<String, Object?> row) => StepData(id: row['step_id'] as int*, steps: row['count of steps'] as int*, distance: row['distance'] as double*, stepDate: row['Date_of_Walking'] as String*, time: row['Walking_time'] as String*)); } │ ^^^^^^ ╵ line 87, column 18 of .: Expected to find '>'. ╷ 87 │ @override Future<List<StepData*>> getAllentrysfromtable() async { return _queryAdapter.queryList('SELECT * from steps_table', mapper: (Map<String, Object?> row) => StepData(id: row['step_id'] as int*, steps: row['count of steps'] as int*, distance: row['distance'] as double*, stepDate: row['Date_of_Walking'] as String*, time: row['Walking_time'] as String*)); } │ ^^^^ ╵ line 101, column 212 of .: Expected to find ')'. ╷ 101 │ @override Future<List<FavoriteRecip*>> getAllEntrysfromTable() async { return _queryAdapter.queryList('SELECT * FROM fav_table', mapper: (Map<String, Object?> row) => FavoriteRecip(id: row['recipe_id'] as int*, recipeName: row['recipe_Name'] as String*, description: row['description'] as String*, picUrl: row['picUrl'] as String*, ingredientslist: row['recipe_ingredients'] as String*, preparationList: row['recipe_preparation'] as String*, kilocal: row['kilocal'] as int*, duration: row['duration'] as int*, recipeTyp: row['recipeTyp'] as String*, savingTimerecipe: row['Time_Recipe_save'] as String*)); } │ ^

flogeiger avatar Jan 06 '22 20:01 flogeiger

same here, I'm using Flutter with 'non-nullable' language feature disabled if it does matter!

PeterMX avatar Feb 20 '22 22:02 PeterMX

solution was using //@dart=2.12 in my entities, dao and DB files as told here https://github.com/vitusortner/floor/issues/558#issuecomment-830622490

PeterMX avatar Feb 20 '22 23:02 PeterMX

solution was using //@Dart=2.12 in my entities, dao and DB files as told here #558 (comment)

Thank you for this! I was struggling and was about to abandon this library altogether.

gatlingxyz avatar Mar 02 '22 15:03 gatlingxyz