Provider: Add extension on BuildContext

Created on 24 Oct 2019  路  1Comment  路  Source: rrousselGit/provider

Hey guys, playing with extensions of dart 2.6, I was thinking on a nice one:

extension ProviderExtensions<T> on BuildContext {
    T provide<T>() => Provider.of<T>(this);
}

Then you could use it like:

  var person = context.provide<Person>();

Would be a nice addition after the extensions functions hit stable :)
What you think?

discussion enhancement

Most helpful comment

Hello!

I'd personally wait to see what Flutter does with extensions, to make sure that provider follows the same prototype/naming convention used by the SDK.

The implementation is easy enough that anybody can copy-paste it on their project, and the gain is minimalist anyway.
So that can definitely wait a bit IMO.

cc @felangel

>All comments

Hello!

I'd personally wait to see what Flutter does with extensions, to make sure that provider follows the same prototype/naming convention used by the SDK.

The implementation is easy enough that anybody can copy-paste it on their project, and the gain is minimalist anyway.
So that can definitely wait a bit IMO.

cc @felangel

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FaizanKamal7 picture FaizanKamal7  路  6Comments

jihongboo picture jihongboo  路  4Comments

MaxTenco picture MaxTenco  路  5Comments

stocksp picture stocksp  路  5Comments

wemped picture wemped  路  5Comments