Access Provider information in Flutter integration test

Viewed 134

I want to access information in one of the Providers used in my app while running integration tests.

I've found some information but doesn't seem to work. I was hoping I could do something like this

      User user;

      await tester.pumpWidget(
        MultiProvider(
          providers: [
            ChangeNotifierProvider.value(value: UsersProvider()),
          ],
          builder: (ctx, child) {
            return Consumer<UsersProvider>(
              builder: (ctx, usersProvider, _) {
                user = usersProvider.user;
                return app.MyApp();
              },
            );
          },
        ),
      );

and then after signing in I was hoping to access properties of the User model stored in the Provider such as; user.verificationState.

e.g.

      if (user.verificationStatus == VerificationStatus.Verified) {
        // Do something based on verification state
      }

but my user is always null.

0 Answers
Related