Home > front end >  flutter with Sqflite : The return type 'Null' isn't a 'Future<_>', as
flutter with Sqflite : The return type 'Null' isn't a 'Future<_>', as

Time:06-03

I have a problem function of Inserted => The return type 'Null' isn't a 'Future<_>', as required by the closure's context

enter image description here

CodePudding user response:

You have to add async to your function.

await database.transaction((txn) async { });

I would also replace then / catchError inside the function with await and try/catch.

CodePudding user response:

If function use async-await then you have to use Future

Future<void> -> function is future and return null
Future<String> -> function is future and return String as output

In above you can replace Future<_> by the return type you expect. I think you have to return int, it will help to know on which row CRUD operation is performed

  • Related