Questions tagged [flutter-hooks]

81 questions
13
votes
5 answers

error `pumpAndSettle timed out` MAYBE due to riverpod

I'm stuck with a widget test and I could use some help to reproduce the behavior please run the code sample below import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'home_page.dart'; void main() =>…
Francesco Iapicca
  • 2,618
  • 5
  • 40
  • 85
8
votes
1 answer

How to test showDialog content in flutter?

is there a way to test the content within a show dialog? I am trying to do BDD in the project, The following is the scenario: As a User, I would like to add a photo or select one from the gallery so that I can use it on the item. The following is…
ncardez
  • 139
  • 2
  • 11
8
votes
3 answers

Flutter Hooks Fetching Data using useEffect - setState() or markNeedsBuild() called during build

Currently exploring functional_widgets and flutter_hooks. Having same idea with reactjs I'm fetching data with the following code. @hwidget Widget homeScreen(BuildContext context) { TodoListProvider model = Provider.of(context); …
Jasper Bernales
  • 1,601
  • 1
  • 11
  • 16
7
votes
4 answers

Using flutter HookWidget and didChangeAppLifecycleState

How can I monitor the life cycle states of the app from a particular page using HookWidget the way you can with a Stateful widget? @override void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); } …
Gerry
  • 1,159
  • 1
  • 14
  • 29
5
votes
3 answers

Creating a custom controller in Flutter

I created a widget named InfiniteScroll which handles asynchronously loaded data and renders it with ListView.builder. However I am having trouble creating a controller for it (for example for clearing all the loaded data). I read through the…
Marcin
  • 184
  • 1
  • 2
  • 12
5
votes
1 answer

Implementing Multiple Pages into a Single Page using Navigation and a Stack

In Flutter, I want to make screens like with Fragment in android, in this my code i try to replace each screens into current screen like with Fragment.replecae in android, i used Hook and Provider and my code work fine when in click on buttons to…
DolDurma
  • 15,753
  • 51
  • 198
  • 377
3
votes
1 answer

How do you show a Dialog / Snackbar inside a useEffect on flutter?

I'm trying to show a Snackbar inside useEffect hook, but it's show me an error. If i a understand well, i can't access the context from inside useEffect. So, how can i do? This is the error: "Cannot listen to inherited widgets inside…
Jibieta
  • 321
  • 2
  • 10
3
votes
0 answers

How to add initial value to TextEditingController with flutter_hooks and riverpod

If I want to add initial value to TextEditingController from Riverpod's provider with hooks, how can I do it? can I use ref.read(someprovider) inside of useTextEditingController like this? final controller = useTextEditingController(text:…
user12208004
  • 1,704
  • 3
  • 15
  • 37
3
votes
2 answers

Riverpod ProviderListener - 'StateNotifierProvider' can't be assigned to 'ProviderBase>'

I'm trying to use a ProviderListener from Riverpod to listen to my authProvider and control the page displayed if a user is authorized or not. I'm getting the error: error: The argument type 'StateNotifierProvider' can't be assigned to…
KatieK
  • 83
  • 2
  • 7
3
votes
1 answer

Riverpods with hooks Flutter - using Provider

Could someone give an example of additional state modifications in Riverpods preferably with riverpod_hooks - I'd like to be able to use it without making an additional widget, so for example: onPress: () { …
3
votes
1 answer

Flutter Hooks - useState initial value

I just started using Flutter Hooks and have been trying to understand how I would initialize a useState hook with a value that is retrieved asynchronously? In my case, from SharedPreferences Normally you would say final boolValue =…
swedishcheef
  • 549
  • 2
  • 11
  • 25
2
votes
1 answer

Riverpod : future provider is stuck on loading

Describe the bug when executing the provider with ref.read or ref.watch the result is the same , it is stuck on the loading block , while testing the api in postman works fine , the funny thing is that the api call gets executed and whenever i print…
Fahmi Sawalha
  • 682
  • 6
  • 19
2
votes
1 answer

How to reload data when using useFuture flutter hook

I'm using Flutter hooks to fetch data by combining useMemorized and useFuture like this: final _latestDocsFuture = useMemoized(() => getLatestDocs()); final _latesetDocsSnapshot = useFuture(_latestDocsFuture); The problem with this hook is I…
2
votes
2 answers

looking up a deactivated widget's ancestor is unsafe => using Riverpod => using "Navigator.of(context).pushReplacementNamed('/page');"

The scenario which I did and caused this Error: 1. after Login page created when I used hot-reload button 2. when I pressed Login-button and state of the page changed. Recently I decided to use riverpod package in my flutter application, so I used…
Taleb
  • 1,944
  • 2
  • 11
  • 36
2
votes
0 answers

How to refresh Riverpod FutureProvider using FlutterHooks useEffect

I am developing mobile application with flutter using flutter hooks. I want to refresh Riverpod FuttureProvider using useEffect, but it doesn't work nicely... My code is @hwidget Widget someWidget(BuildContext context) { final futureProvider =…
1
2 3 4 5 6