provider

Dart Provider: not available at the immediate child

旧巷老猫 提交于 2020-12-15 05:01:51
问题 @override Widget build(BuildContext context) { return BlocProvider<HomeBloc>( create: (context) { return HomeBloc(homeRepo: HomeRepository()); }, child: BlocProvider.of<HomeBloc>(context).state is HomeStateLoading ? CircularProgressIndicator() : Container()); } I am confused with the error: BlocProvider.of() called with a context that does not contain a Bloc of type HomeBloc. No ancestor could be found starting from the context that was passed to BlocProvider.of<HomeBloc>(). Didn't I just

Pass user uid to Firestore stream query in Flutter

情到浓时终转凉″ 提交于 2020-12-06 11:57:21
问题 Here I am using provider in main.dart to stream "itemsInUserDocument" data from a document. Widget build(BuildContext context) { return MultiProvider( providers: [ StreamProvider<DocumentSnapshot>.value( value: DatabaseService().itemsInUserDocument, <--- (1) Providing here ), StreamProvider<User>.value( value: AuthProvider().user, ), ], My problem is passing the userUID to the Stream query here. My document id's on Firestore is my userUID. final userUID = "3SlUigYBgsNgzjU8a9GSimhAhuu1"; <--

Flutter Provider: what is the best way to dispatch the action properly?

拟墨画扇 提交于 2020-06-29 03:39:55
问题 The question is related to my previous question: Why can't I use context.read in build(), but I can use Provider.of with listen: false? You said that an old Provider.of<X>(context, listen: false) syntax is unsafe. However, it works. I believe fetchTransactions() method won't change, so there's no need to watch it. I can't use context.read because it's not in the closure and will throw the "don't use context.read in a build method" error. I can't use context.watch or context.select with

Why can't I use context.read in build(), but I can use Provider.of with listen: false?

前提是你 提交于 2020-06-25 18:38:06
问题 It's stated in the docs that these are the same, and context.read is just a shortcut for Provider.of<x>(context, listen: false) . There's also an error in the console if I try to use context.read in a build method, but it doesn't explain the reason. I also found this topic: Is Provider.of(context, listen: false) equivalent to context.read()? But it doesn't answer "why". 回答1: context.read is not allowed inside build because it is very dangerous to use there, and there are much better solutions

Problems while using Flutter Provider package

和自甴很熟 提交于 2020-06-16 04:11:18
问题 I am creating a very simple app to practice flutter provider package. The app has a bulb which on click , should change it's background and the screen's background , using provider. But this doesnt seem to work. TBH this is a lot confusing import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; void main() => runApp(MainApp()); class Data extends ChangeNotifier{ bool isOn = false; void toggle(){ this.isOn = !this.isOn; notifyListeners(); print("new value is $isOn"); }

Flutter provider not working in release apk, but working fine in debug mode

≡放荡痞女 提交于 2020-05-29 07:43:11
问题 the provider should work to provide real time updates to consumers but only works in debug mode and not release mode. do i have to use the state full widget again to update the ui with set state, any clue? 回答1: Might be possible that you missed to add internet permission in AndroidManifest.xml <uses-permission android:name="android.permission.INTERNET" /> We have to add Internet permission in AndroidManifest.xml file for release build. It is working fine in debug mode. If you have been

Flutter provider not working in release apk, but working fine in debug mode

夙愿已清 提交于 2020-05-29 07:41:06
问题 the provider should work to provide real time updates to consumers but only works in debug mode and not release mode. do i have to use the state full widget again to update the ui with set state, any clue? 回答1: Might be possible that you missed to add internet permission in AndroidManifest.xml <uses-permission android:name="android.permission.INTERNET" /> We have to add Internet permission in AndroidManifest.xml file for release build. It is working fine in debug mode. If you have been

Legacy Java code use of com.sun.net.ssl.internal.ssl.Provider()

我的梦境 提交于 2020-05-23 08:18:10
问题 I am working with some code from back in 2003. There is a reference to the following class: new com.sun.net.ssl.internal.ssl.Provider() It is causing an error: Access restriction: The type Provider is not accessible due to restriction on required library /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/jsse.jar Does anyone have any suggestions for a suitable alternative to using this class? 回答1: Most of the time, you don't actually need to create or get hold of a provider