Riverpod – FutureProvider refresh data, does go to loading

I’m using FutureProvider in Riverpod for Flutter to return an API call with data and update the UI. While its loading it shows the CircularIndicator, then when loaded it displays the data on the home page. This is working the first time. However, at a later stage in the app, the user triggers the call… Read More Riverpod – FutureProvider refresh data, does go to loading

How can I use Future<> riverpod example on Flutter?

@riverpod Future<String> boredSuggestion(BoredSuggestionRef ref) async { final response = await http.get( Uri.https(‘https://www.boredapi.com/api/activity&#8217;), ); final json = jsonDecode(response.body) as Map; return json[‘activity’]! as String; } class Home extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final boredSuggestion = ref.watch(boredSuggestionProvider); // Perform a switch-case on the result to handle loading/error states return boredSuggestion.when( loading: ()… Read More How can I use Future<> riverpod example on Flutter?

Flutter riverpod: 'Bad State No ProvderScope found' after using navigator

I have the following scanario: i`m using the riverpod state management across the application and everything works fine, but when I try to use in a screen that I reach using Navigator, the following error appear: Bad state: No ProviderScope found Event: ListTile( leading: Icon(Icons.currency_exchange), title: Text(‘Currency’), onTap: () => Navigator.of(context).push( MaterialPageRoute(builder: (context) => const… Read More Flutter riverpod: 'Bad State No ProvderScope found' after using navigator

ProviderScope not defined issue

I am trying to migrate an old Flutter project to Null Safety. This is the main.dart code: import ‘dart:async’; import ‘dart:convert’; import ‘package:capenergy_ns/pantallas/my_home_screen.dart’; import ‘package:easy_localization/easy_localization.dart’; import ‘package:flutter/material.dart’; import ‘package:shared_preferences/shared_preferences.dart’; import ‘package:riverpod/riverpod.dart’; import ‘package:flutter_localizations/flutter_localizations.dart’; import ‘package:splashscreen/splashscreen.dart’; import ‘constantes/constantes.dart’; Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); SharedPreferences prefs = await SharedPreferences.getInstance(); var email = prefs.getString(’email’); runApp( ProviderScope( child: EasyLocalization(… Read More ProviderScope not defined issue