Questions tagged [flutter-hooks]

81 questions
0
votes
0 answers

Hive boxes are deleted when app closes or restart

The problem is that Hive is acting unexpectedly, and when the app closes or I restart it all, the data in the box is cleared. main.dart: void main() async { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setSystemUIOverlayStyle( …
Fahmi Sawalha
  • 682
  • 6
  • 19
0
votes
1 answer

flutter_hooks useState value is being reset to the initial value upon popping the stack

I have this useState: class RegisterFormPageWidget extends HookConsumerWidget { const RegisterFormPageWidget({Key? key}) : super(key: key); @override Widget build(BuildContext context, WidgetRef ref) { final vm =…
BeniaminoBaggins
  • 11,202
  • 41
  • 152
  • 287
0
votes
1 answer

Flutter Hooks: Getting error while using useEffect with TextEditingController

I want to use useEffect with TextEditingController instead of useTextEditingController. Error: late Initialization Error. Am I not writing init and disposing correctly? class EffectTest extends HookWidget { const EffectTest({super.key}); …
Anmol Singh
  • 393
  • 3
  • 16
0
votes
1 answer

Modifying Lists inside of classes - Flutter, Riverpod, Hooks

I would like to have a class that contains a list of another class and be able to update it using Riverpod/Hooks. I'm trying to figure out the best syntax or even way to approach the issue. I'm starting with a StateProvider to make it simpler and…
KatieK
  • 83
  • 2
  • 7
0
votes
1 answer

Is there a way I can have my HookWidget rebuild when the text of the TextEditingController changes?

I have a test edit field. When there is no text, I want a button disabled. When there is text in the TextField, I want the button enabled. I am using flutter_hooks to reduce boiler plate code for controllers. In the following example, when I enter…
Scorb
  • 1,654
  • 13
  • 70
  • 144
0
votes
1 answer

FLUTTER - How to properly upgrade this code to work with RiverPod 1.0+?

I added the libraries to pubspec.yaml. In the current project I am not using hooks, but used the package because I want to use this to build a skeleton starter project. pubspec.yaml: flutter_hooks: ^0.18.2+1 hooks_riverpod: ^1.0.3 Then I…
0
votes
0 answers

Remove listener from FocusNode using Flutter Hooks

I started adopting Flutter Hooks recently and REALLY loving it. I was able to convert a few of my StatefulWidgets to HookWidgets, and it's pretty cool. The one thing I'm struggling to figure out is how to properly remove listeners from from a…
Mr. Oak
  • 179
  • 9
0
votes
0 answers

Set() is not working in Flutter when I use Flutter Hooks

I wanted to create a checklist for the programming languages I know. I have used Set() to contain the data. But when I use it in the CheckboxListTile() it is not checking the box in the UI. I wanted to do it with using flutter_hooks. I have created…
Praveen117
  • 11
  • 3
0
votes
1 answer

Using useFuture conditionally

I've been working with flutter-hooks' useFuture method, but I need to use it conditionally (based on user-input in this case). I've found this approach, but I need to know if there is a better way: Storing what data is selected using useState, and…
teslafan0
  • 25
  • 4
0
votes
1 answer

Is HookConsumerWidget still a part of hooks_riverpod.dart?

I am working on building some of the example hooks_riverpod applications and I get an error that the HookConsumerWidget is not a dart class. Is this still a valid widget in the latest version or has it been changed? Thanks.
0
votes
1 answer

Access Providers from Dialogs for Flutter hooks

I am new to Flutter hooks and riverpod Basically I have a provider that stores the list of books in a book shelf. class BookList extends StateNotifier> { BookList() : super([]); void setBookList(List bookList) => …
0
votes
1 answer

Flutter Hooks. Where to "requestPermission" as it doesn't have an initState

I am learning Flutter Hooks, but I can't find anything about what to use when you need to have a specific permission request which usually goes in the initState, for example: class _HomePageState extends State { @override void…
groo
  • 4,213
  • 6
  • 45
  • 69
0
votes
1 answer

Read riverpod stream value in useEffect

I want to read the first value from a list stream in useEffect to select the first value in the list returned. How do I do this differently. Shows an error on restart. I am using hooks_riverpod final _locations =…
Shei
  • 393
  • 4
  • 15
0
votes
0 answers

Bad state: Stream has already been listened to. (useStream doesn't close the stream)

In my HookWidget, I call: final myData = useStream(service.getDataStream(), initialData: {}); Unfortunately, when going back to the same screen/ navigating, I get Bad state: Stream has already been listened to.. This is probably because the…
Ben Butterworth
  • 22,056
  • 10
  • 114
  • 167
0
votes
1 answer

Force a widget tree build using a Hook Widget in Flutter

I have a page that dynamically accepts a future list and a callback to get the future list to receive data and be able to refresh it through on refresh. a simplified version looks like this: class ListSearchPage extends StatefulWidget { final…
Jose Georges
  • 883
  • 8
  • 16