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

Transaction: a nullable return type becomes not nullable in the method's implementation #557

Closed
Mabsten opened this issue Apr 30, 2021 · 1 comment · Fixed by #559
Closed

Comments

@Mabsten
Copy link

Mabsten commented Apr 30, 2021

Step to reproduce the issue:

  • add this simple method to the TaskDao class in the official example

    @transaction
     Future<Task?> test(int id) {
       return findTaskById(id);
     }
  • run flutter pub run build_runner build

Generated code:

  @override
  Future<Task> test(int id) async {
    if (database is sqflite.Transaction) {
      return super.test(id);
    } else {
      return (database as sqflite.Database)
          .transaction<Task>((transaction) async {
        final transactionDatabase = _$FlutterDatabase(changeListener)
          ..database = transaction;
        return transactionDatabase.taskDao.test(id);
      });
    }
  }

This code doesn't compile because the method is declared with a not nullable return type, and also sqflite.Database.transaction<Task>(..) (in the else branch) is invoked with a not nullable parametric type

@Mabsten Mabsten changed the title Re Transaction: a nullable return type becomes not nullable in the method's implementation Apr 30, 2021
@StarkShang
Copy link

This append is 1.2.0 again even with annotation on top of database.dart file:

//@Dart=2.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants