How to use data from Provider during initState in Flutter application

You need to use the context to call Provider.of() so you can add addPostFrameCallback() which is called after the first build, there you can use the context @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { auth = Provider.of<Auth>(context, listen: false); }); }

Do not use BuildContexts across async gaps

Don’t stock context directly into custom classes, and don’t use context after async if you’re not sure your widget is mounted. Do something like this: class MyCustomClass { const MyCustomClass(); Future<void> myAsyncMethod(BuildContext context, VoidCallback onSuccess) async { await Future.delayed(const Duration(seconds: 2)); onSuccess.call(); } } class MyWidget extends StatefulWidget { @override _MyWidgetState createState() => _MyWidgetState(); } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)