Giter VIP home page Giter VIP logo

Comments (6)

rrousselGit avatar rrousselGit commented on September 27, 2024

Correct. This is unsupported.

If you wish for your object to be used with AbstractCubit instead of IntCubit, have your provider use AbstractCubit:

BlocProvider<AbstractCubit<int>>(

from provider.

Jannik-dev avatar Jannik-dev commented on September 27, 2024

Thanks for the quick reply, but simply providing AbstractCubit instead of IntCubit does not work, since I need the IntCubit functionality in another part of the app (in this example the doStuff method). But I don't want to use IntCubit in BlocWidget, because it does not need it.

My only idea right now is to provide IntCubit as AbstractCubit and as IntCubit but I dislike this approach too, because there could be more classes in the hierarchy.

from provider.

rrousselGit avatar rrousselGit commented on September 27, 2024

What you're asking is not possible in any case. You'll always have to write extra logic to support both context.watch<AbstractCubit<int>> and context.watch<IntCubit>

from provider.

Jannik-dev avatar Jannik-dev commented on September 27, 2024

Why cannot context.watch<AbstractCubit<int>> use the IntCubit? I mean, the IntCubit is an AbstractCubit<int>. Is there no simple way how I can use abstractions?

from provider.

rrousselGit avatar rrousselGit commented on September 27, 2024

That's not how InheritedWidgets work. They use exact type matching. There's no such thing as specifying a type, but getting a subclass instead. You have to manually expose your provider with said type. No way around it.

from provider.

Jannik-dev avatar Jannik-dev commented on September 27, 2024

Thank you very much for your explanation

from provider.

Related Issues (20)

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.