Questions tagged [flutter-hooks]
81 questions
1
vote
1 answer
why can't I see updates to the value of useTextEditingController?
I would expect the effect to log the current value of the text whenever it changes, but it only runs for the initial value. Why?
class RecordForm extends HookWidget {
final Record? record;
const RecordForm({
Key? key,
this.record,
}) :…

Stuck
- 11,225
- 11
- 59
- 104
1
vote
1 answer
Where/When to perform operations such as sorting, grouping with a StateNotifier controller?
I am wondering when/where to perform operations after HTTP request done with a RESTFUL API.
I am using a StateNotifdier as a mean of Controller to perform simple CRUD operations such as retrieveItems, addItem, updateItem and deleteItem.
I would need…

Chris
- 31
- 3
1
vote
1 answer
StateNotifierProvider not updating state using HookWidget
I am trying to use Riverpod state management. I have two TextFormField and I want to set the value of a Text by taking the sum of the values entered in each of the fields using a StateNotifierProvider.
In the following code, CashCounterData is a…

DolDurma
- 15,753
- 51
- 198
- 377
1
vote
1 answer
Flutter Hooks and async calls
some noob questions ahead.
I'm using Flutter Hooks in my app, but struggling when trying to use hooks with calls that are async.
For example, how to get SharedPreferences through useMemoized (or any other async data with hooks)?
SharedPreferences…

Marcus M.
- 79
- 2
- 10
1
vote
0 answers
Flutter: How to rebuild specific part of UI using hooks?
I'm trying to move my TextFormField logic to flutter hooks so I have password field where I want implement obscure text. So on tap of button it should hide/unhide the text. Now I using setState() in the hooks to do that but it rebuilds the whole UI…

Pokaboom
- 1,110
- 9
- 28
1
vote
0 answers
Flutter: how can use hooks to change the visibility of text in textformfield?
I'm trying to move my TextFormField logic to hooks but what I'm trying is doesn't seem to work.
my custom hook,
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
enum…

Pokaboom
- 1,110
- 9
- 28
1
vote
0 answers
How to use didChangeAppLifecycleState with Flutter Hooks
I am using Flutter with hooks and I am trying to get the App Life Cycle State. I followed documentation and created new hook (code shown below) which works ok for all situations with one exception. When the application state becomes "paused", the…

Aimn Blbol
- 907
- 11
- 20
1
vote
1 answer
unable to use both useFuture() and useValueChanged() in same HookWidget
I have a hook widget with useValueChanged listener as follows:
useValueChanged(selectedLayout.value, (_, __) {
changeLayout(selectedLayout.value);
});
and changeLayout(..) uses useFuture(..) to make a graphql mutation call and return…

Shanthakumar
- 757
- 6
- 23
1
vote
0 answers
What's the real use of useContext flutter hook when it can't be called outside the build method?
I recently started working with flutter_hooks but then I wondered what is the benefit of having a hook that returns the build context in the build method that is already provides the build context..!!
Have anyone a good explanation for this?

devmuaz
- 519
- 7
- 18
1
vote
1 answer
Is there GlobalKey counterpart of HookWidget?
I want to call the onPopPage in the following code in the parent widget.
In traditional way I may use GlobalKey().currentState.someMethod.
But what's the desirable way with HookWidget?
class SomeWidget extends HookWidget {
final…

jeiea
- 1,965
- 14
- 24
1
vote
1 answer
Flutter useAnimationController hook doesn't rebuild widget
I'm using the flutter hooks package to animate an element on screen, but I've obviously done something wrong seeing as the element doesn't rebuild to animate. this is the code I have.
class Ball extends HookWidget {
@override
Widget…

Ben Baldwin
- 427
- 1
- 6
- 13
1
vote
2 answers
flutter hook useContext example
Is there any example of useContext() function example?
I want to use
AppLocalizations.of(context).someText
in many of hook widgets and I am not sure if it is just enough to wrap it in useEffect function on initialize.

hyobbb
- 332
- 1
- 9
1
vote
0 answers
Is the context necessary in custom hooks?
According to the Flutter hooks documentation on creating custom hooks, the author mentioned an example like the following,
ValueNotifier useLoggedState(BuildContext context, [T initialData]) {
final result = useState(initialData);
…

Frenco
- 1,299
- 1
- 8
- 25
0
votes
1 answer
Call a provider with flutter hooks
I had previously developed a Flutter app using Riverpod(StateNotifierProvider, and everything was working smoothly. Recently, I've been trying to migrate from regular Riverpod to Riverpod Generator(NotifierProvider) and Flutter Hooks. However, I've…

Nashaf
- 23
- 7
0
votes
0 answers
Get Auto_Route nested AutoRouter()'s route stack in parent page and rebuild when it changes, using Hooks/Riverpod
I'm trying to make a UI shell for my app using nested Auto_Route routes, and one thing I want the shell to have is a breadcrumb navigation bar to show the stack of routes and let you click on any to pop back to it.
So I have a simple AppShellPage.…

Tristan King
- 438
- 4
- 17