Code Monkey home page Code Monkey logo

flutter-provide's Issues

How to use multi values of provider in one Widget?

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)
    );

About operator priority problem

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);
}

Build fail: Provider.stream(Stream, {}) conflicts to Provider.stream(BuildContext)

Build log

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.

Reproduce

  • flutter create hello
  • add "provide ^1.0.1" to dependencies in pubspec.yaml
  • add "import 'package:provide/provide.dart';" to main.dart
  • flutter build apk --release/debug OR flutter build ios --release/debug --no-codesign

Flutter Doctor

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.

How can I push a new page without buildContext?

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.

Is this a duplicate of "provider"?

👋 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?

provider is Listenable

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.