Skip to content

Migrate project to Null Safety#7

Open
bizz84 wants to merge 5 commits intomasterfrom
null-safety-migration
Open

Migrate project to Null Safety#7
bizz84 wants to merge 5 commits intomasterfrom
null-safety-migration

Conversation

@bizz84
Copy link
Copy Markdown
Owner

@bizz84 bizz84 commented Mar 8, 2021

No description provided.

@fogelfish
Copy link
Copy Markdown

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?

@bizz84
Copy link
Copy Markdown
Owner Author

bizz84 commented Mar 20, 2021

@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.

@pawelpetruch
Copy link
Copy Markdown

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

Copy link
Copy Markdown

@dmalikyar dmalikyar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change line 36 in the firestore_service.dart file
from:
.map((snapshot) => builder(snapshot.data(), snapshot.id))
to:
.map((snapshot) => builder(snapshot.data() as Map<String, dynamic>, snapshot.id))
In order to build the project. Flutter 2.8.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants