skip to Main Content

Flutter – Why is there Error getting value from FutureBuilder?

class TodoList extends ChangeNotifier{Future<bool> GetLoginData() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); notifyListeners(); return prefs.getBool('data')??false; }} class _CheckState extends State<Check> { Widget build(BuildContext context) { final x = Provider.of<TodoList>(context); print(x.GetLoginData().toString()); return FutureBuilder<bool>( future: x.GetLoginData(), builder: (context, snapshot) { if…

VIEW QUESTION

flutter reload page not working when i use provider

I'm using provider. The problem in the code below is that I can't reload the API. @override void initState() { super.initState(); getData(context); } Future<void> getData(BuildContext context) async { final provider = Provider.of<AppDataProvider>(context, listen: false); final userId = provider.userId; await Future.wait([…

VIEW QUESTION

How to use flutter provider in initState

This the provider details I am having //is_products_changed_provider.dart import 'package:flutter/material.dart'; class IsProductChangedProvider extends ChangeNotifier { bool isTheProductChanged = true; void changeIsTheProductChanged() { isTheProductChanged = !isTheProductChanged; notifyListeners(); } } Now I want to use it in the products page, i.e. If…

VIEW QUESTION

Flutter – Error: Could not find the correct Provider<ThemeProvider> above this MyApp Widget

I've got a problem, my code doesn't work. I've looked through some of the already existing posts, but nothing has worked. my main.dart looks like this import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:study_sync/auth/login_or_register.dart'; import 'package:study_sync/theme/theme_provider.dart'; void main() { runApp(const MyApp()); }…

VIEW QUESTION
Back To Top
Search