Questions tagged [flutter-hooks]

81 questions
2
votes
1 answer

Flutter Hooks Riverpod not updating widget despite provider being refreshed

I've been studying flutter for a couple of months and I am now experimenting with Hooks and Riverpod which would be very important so some results can be cached by the provider and reused and only really re-fetched when there's an update. But I hit…
groo
  • 4,213
  • 6
  • 45
  • 69
2
votes
1 answer

Riverpode and Hooks in flutter, how to implement the StateNotifier for async calls?

I am new to flutter and recently I decided to look into providers to be able to reuse some sqlite DB calls I have using FutureBuilder as suggested in this other question. After reading about it I started using riverpod_hooks but I got…
groo
  • 4,213
  • 6
  • 45
  • 69
2
votes
1 answer

Pass and update State Value from other function Flutter Hook Widget

I am new to Flutter hooks and I have requirements that I have to use HookWidget instead of StatefulWidget. As I know, useState can only be declared within the build function. Widget build(BuildContext context) { final selectedBook =…
Avan CaiJun
  • 111
  • 1
  • 1
  • 11
2
votes
1 answer

Using video_player package with Flutter Hooks to play a background fullscreen video

I have a Home Screen Widget, that plays a fullscreen background video using the video_player package. This code works fine for me: class HomeScreen extends StatefulWidget { HomeScreen({Key key}) : super(key: key); @override _HomeScreenState…
2
votes
0 answers

Completer Flutter hook causes bad state error

For managing pull-to-refresh indication in Flutter with BLoC I created a custom Completer hook as an alternative to using a Stateful Widget, and in general, it works fine, however with hot-reload I run into Bad state: Future already completed import…
RemeJuan
  • 823
  • 9
  • 25
1
vote
2 answers

Is there a use for hooks_riverpod

I'm kinda confused as to what exactly the aim is with hooks_riverpod, I've used flutter_riverpod, and I've used flutter_hooks, but what is hooks_riverpod, on the pub.dev main page for hooks_riverpod, it's documentation is just flutter_riverpod…
1
vote
1 answer

Getting error when trying to add WidgetRef parameter to the build method in Flutter

void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); runApp( const ProviderScope( child: MyApp(), ), ); } class MyApp extends…
user1543784
  • 271
  • 2
  • 4
  • 19
1
vote
1 answer

Flutter: Update widgettree (with hooks) when variable from class changes

So basically I have a class that handles all my bluetooth connection. Inside this class there are also some variables that I need inside my Widgettree. I need to listen for updates on these variables but that doesn't work out like I want it to. In…
1
vote
2 answers

Riverpod with hooks beaks when widget is disposedI

I have Flutter mobile app that is using Riverpod with hooks. I have the following function that I would like to be called when the widget is disposed: useEffect( () { final firestoreRepo = …
Aimn Blbol
  • 907
  • 11
  • 20
1
vote
0 answers

How to fetch and keep updated data with flutter_hooks?

I'm studying flutter_hooks library. My aim is to fetch data into model and be able to refresh it any time. Also I'd like to refresh data from different screens. Currently I do it this way: Page class: class NewPage extends HookWidget{ @override …
undefined
  • 623
  • 7
  • 27
1
vote
1 answer

How to update the initialData of "useState" from parent in Flutter Hooks

According to the description of useState in flutter_hooks: ... /// On the first call, it initializes [ValueNotifier] to [initialData]. [initialData] is ignored /// on subsequent calls. ... I want to use useState to change the current widget state.…
yellowgray
  • 4,006
  • 6
  • 28
1
vote
0 answers

How to Call a Graphql Query again for every letter entered in autocomplete widget flutter?

I am able to search in a list using autocomplete widget in flutter and display the options to the user. But actually what I am supposed to do is I have to call graphql query everytime as user enters a letter/alphabet in autocomplete widget. I have…
Cassius
  • 353
  • 3
  • 16
1
vote
0 answers

Does Timer.periodic need to be cancelled on widget unmount?

I'm using flutter hooks, and using the Timer.periodic to do some processing in my widget. Here's how I'm using it: final countdownStream = useMemoized( () => Timer.periodic( // ... ), ); Do I need to cancel this or will…
user1354934
  • 8,139
  • 15
  • 50
  • 80
1
vote
2 answers

deleting an element always delete the last one in flutter

List storedWishes = [ { 'title': 'Phone', 'description': 'a phone would be nice', 'price': 200.00, 'icon': Icon(Icons.phone) }, { 'title': 'monitor', 'description': 'need it for a 2…
1
vote
1 answer

TextEditingController behaviour in custom text field

I composed a custom text field that check the validator when it lost focus, with some UI such as error text and green checked icon. They are working fine until I need to perform some auto-filling according to other TextField's data. When user filled…
Mervyn Lee
  • 1,957
  • 4
  • 28
  • 54