time_tracker_flutter_course icon indicating copy to clipboard operation
time_tracker_flutter_course copied to clipboard

Migrate project to Null Safety

Open bizz84 opened this issue 3 years ago • 3 comments

bizz84 avatar Mar 08 '21 11:03 bizz84

Andrea, it has been incredibly helpful to have this non-trivial example of migrating to Null Safety to learn from. I really appreciate your doing this for the time_tracker course. I have questions about how dart analysis evaluates some code in email_form_sign_in_stateful_test.dart. For example, in this method...

  void stubSignInWithEmailAndPasswordSucceeds() {
    when(mockAuth.signInWithEmailAndPassword(any!, any!))
        .thenAnswer((_) => Future<User>.value(MockUser()));
  }

...this code is marked as dead code:

any!))
        .thenAnswer((_) => Future<User>.value(MockUser()));

And both any! arguments give this result in the analysis:

info: This null-check will always throw an exception because the expression will always evaluate to 'null'. (null_check_always_fails at [time_tracker] test/email_form_sign_in_stateful_test.dart:37)

Are these results unavoidable at this time?

fogelfish avatar Mar 10 '21 17:03 fogelfish

@fogelfish some of the code in the test files is not finalized yet. As I pointed out in this article, there are some problems with mockito and null-safety. You'll notice that some tests have skip: true.

So yeah, don't use my test code as reference as this is not ready just yet.

bizz84 avatar Mar 20 '21 21:03 bizz84

@bizz84 maybe use mocktail? It's way more comprehensive when migrating to null safety.

pawelpetruch avatar May 21 '21 19:05 pawelpetruch