2

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.

Chris
  • 1,720
  • 16
  • 35
  • For easier testing you should migrate from Provider to Riverpod as Provider will be probably deprecated soon, when Riverpod is a continuation. – Karol Wiśniewski May 08 '23 at 06:38

0 Answers0