I want use Firebase Auth in Flutter project. And I am use provider
. Everything is okey but I am facing one issue with provider
.
My IconButtonWidget:
class SocialIconButton extends StatelessWidget {
final String socialIcon;
const SocialIconButton({Key? key, required this.socialIcon})
: super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: context.dynamicWidth(20)),
child: IconButton(
onPressed: (() {
final provider =
Provider.of<GoogleSignInProvider>(context, listen: false);
provider.login();
}),
icon: Image.asset(socialIcon)),
);
}
}
When I press button I am facing this issue:
ProviderNotFoundException (Error: Could not find the correct Provider<GoogleSignInProvider> above this SocialIconButton Widget.
Wrap your App with MultiProvider and provide instance like
void main() {
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => GoogleSignInProvider()),
],
child: const MyApp(),
),
);
}
More about provider. Also you can check riverpod2