google / flutter-provide Goto Github PK
View Code? Open in Web Editor NEWA simple framework for state management in Flutter.
Home Page: https://pub.dartlang.org/packages/provide
License: BSD 3-Clause "New" or "Revised" License
A simple framework for state management in Flutter.
Home Page: https://pub.dartlang.org/packages/provide
License: BSD 3-Clause "New" or "Revised" License
For example: in the code below, how to use counter
and switcher
in one widget?
Neither Provide.value<T>
or StreamBuilder<T>
seems to be fited for this.
var counter = Counter();
var switcher = Switcher();
var providers = Providers();
providers
..provide(Provider<Counter>.value(counter))
..provide(Provider<Switcher>.value(switcher));
runApp(
ProviderNode(
child: MyApp(),
providers: providers)
);
Explain:
'||' > '??' Actually,
so 'parent?.updateShouldNotify(oldWidget.parent) ??
false || providers != oldWidget.providers' equals 'parent?.updateShouldNotify(oldWidget.parent) ??
providers != oldWidget.providers'
Suggestion:
change
"@OverRide
bool updateShouldNotify(_InheritedProviders oldWidget) {
return parent?.updateShouldNotify(oldWidget.parent) ??
false || providers != oldWidget.providers;
}"
to
"@OverRide
bool updateShouldNotify(_InheritedProviders oldWidget) {
return providers != oldWidget.providers ? true : (parent ?.updateShouldNotify(oldWidget.parent) ?? false);
}
difference between bloc and this repo?
Bloc has 'sink.addError(e)' to notify Widget,what if I want to get errors with Provide?
Don't give up, get active, continue to improve
For me, this is the easiest to use state management solution at the moment.
Please continue to improve it.
Compiler message:
file:///Users/sunbreak/lib/flutter/.pub-cache/hosted/pub.flutter-io.cn/provide-1.0.1/lib/provide.dart:220:11: Error: Can't declare a member that conflicts with an inherited one.
factory Provider.stream(Stream<T> stream, {T initialValue}) =>
^
file:///Users/sunbreak/lib/flutter/.pub-cache/hosted/pub.flutter-io.cn/provide-1.0.1/lib/provide.dart:192:13: Context: This is the inherited member.
Stream<T> stream(BuildContext context);
^
Compiler terminated unexpectedly.
bogon:~ sunbreak$ flutter doctor -v
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.3 18D109, locale en-CN)
• Flutter version 1.0.0 at /Users/sunbreak/lib/flutter
• Framework revision 5391447fae (3 months ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /Users/sunbreak/lib/android-sdk-macosx
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/sunbreak/lib/android-sdk-macosx
• Java binary at: /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.5.3
[!] Android Studio (version 3.3.1)
• Android Studio at /Users/sunbreak/Applications/JetBrains Toolbox/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[✓] IntelliJ IDEA Ultimate Edition (version 2018.3.4)
• IntelliJ at /Users/sunbreak/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
• Flutter plugin version 33.1.2
• Dart plugin version 183.5901
[✓] VS Code (version 1.31.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.23.0
[✓] Connected device (1 available)
• sunbreak-iPhoneX • fea92a66dcc76d390a73c235d7de105436174b38 • ios • iOS 12.1.2
! Doctor found issues in 2 categories.
In Redux I can use navigatorKey.currentState.pushNamed('/someRoute');
to push a new page with out pass the context.
How can I do the same thing in flutter-provide
?
example:
I want to push the Login Page in my SomeNetwork.dart When get a response with status_code = 401.
Why is it not updated? I think it is very easy to use.
Similar to:
reactiveui/ReactiveUI#979
PrismLibrary/Prism#1016
orientechnologies/orientdb#4806
brianegan/flutter_redux#86
felangel/bloc#139
If anyone is using the library then please give your input.
Use the following template:
If available on stores
iOS:
Android:
If open source
Source Code:
Your opinion
Version: ?
Years of experience: ?
Good: ?
Bad: ?
Thank you very much!
👋 maintainer of provider here
It seems that this library aims at doing exactly what mine does: a set of generic providers to replace Inheritedwidget.
The main selling point of flutter-provide
seem to be able to use multiple providers at once; which is already supported by provider
through MultiProvider
What is the reasoning by creating a new one?
when I see Provide.dart ,In the 276 line ,
listenable = _getListenable(provider, value); I jump this method,
Listenable _getListenable(Provider provider, dynamic value) =>provider is Listenable ? provider : value is Listenable ? value : null;
I want to konw ,this provider when to extend Listenable?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.