Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERROR] Queries returning single elements might return null. #837

Open
koloyyee opened this issue Jul 22, 2024 · 0 comments
Open

[ERROR] Queries returning single elements might return null. #837

koloyyee opened this issue Jul 22, 2024 · 0 comments

Comments

@koloyyee
Copy link

koloyyee commented Jul 22, 2024

This is on and off bug I noticed, something it works something it does,
I removed the build, pubspec.lock, flutter clean, flutter doctor, flutter pub get, still not working,
any way to fix it?, thank you.

even better if any way that I can debug it myself? thank you

dependencies
    sqflite: any

dev_dependencies:
  flutter_test:
    sdk: flutter
  floor_generator: ^1.4.0
  build_runner: ^2.1.2

Here is my @dao code

@Query("select  * from Staffs  where id = :id;")
  Future<Staff?>findStaffById(int id);

  @Query("select * from Staffs where email = :email;")
  Future<Staff?>findStaffByEmail(String email);

Here is console error log

Queries returning single elements might return null. Make the method return a Future of a nullable type e.g. Future<Person?>.
package:i_can_fly/dao/staff-dao.dart:11:17
   ╷
11 │   Future<Staff?>findStaffById(int id);
   │                 ^^^^^^^^^^^^^
   ╵
package:floor_generator/processor/query_method_processor.dart 140:9  QueryMethodProcessor._assertReturnsNullableSingle
package:floor_generator/processor/query_method_processor.dart 53:5   QueryMethodProcessor.process
package:floor_generator/processor/dao_processor.dart 91:15           DaoProcessor._getQueryMethods.<fn>
dart:core                                                            Iterable.toList
package:floor_generator/processor/dao_processor.dart 92:10           DaoProcessor._getQueryMethods
package:floor_generator/processor/dao_processor.dart 55:26           DaoProcessor.process
package:floor_generator/processor/database_processor.dart 89:9       DatabaseProcessor._getDaoGetters.<fn>
dart:core                                                            Iterable.toList
package:floor_generator/processor/database_processor.dart 92:8       DatabaseProcessor._getDaoGetters
package:floor_generator/processor/database_processor.dart 36:24      DatabaseProcessor.process
package:floor_generator/generator.dart 72:39                         FloorGenerator._getDatabase
package:floor_generator/generator.dart 26:22                         FloorGenerator.generateForAnnotatedElement
package:source_gen/src/generator_for_annotation.dart 61:30           GeneratorForAnnotation.generate
package:source_gen/src/builder.dart 342:33                           _generate
dart:async                                                           Stream.toList.<fn>
package:source_gen/src/builder.dart 107:9                            _Builder._generateForLibrary
package:source_gen/src/builder.dart 99:5                             _Builder.build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant