https://github.com/hoc081098/flutter_provider
:octocat: Flutter generic provider using InheritedWidget. Flutter generic provider using InheritedWidget. An helper to easily exposes a value using InheritedWidget without having to write one.
https://github.com/hoc081098/flutter_provider
flutter-provider inherited-widget inheritedwidget provider provider-flutter provider-state-management
Last synced: 4 days ago
JSON representation
:octocat: Flutter generic provider using InheritedWidget. Flutter generic provider using InheritedWidget. An helper to easily exposes a value using InheritedWidget without having to write one.
- Host: GitHub
- URL: https://github.com/hoc081098/flutter_provider
- Owner: hoc081098
- License: mit
- Created: 2019-03-31T07:38:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-09-19T03:53:36.000Z (28 days ago)
- Last Synced: 2025-10-13T12:04:13.935Z (4 days ago)
- Topics: flutter-provider, inherited-widget, inheritedwidget, provider, provider-flutter, provider-state-management
- Language: Dart
- Homepage: https://pub.dev/packages/flutter_provider
- Size: 4.79 MB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# flutter_provider
## Author: [Petrus Nguyễn Thái Học](https://github.com/hoc081098)
[](https://pub.dartlang.org/packages/flutter_provider)
[](https://travis-ci.org/hoc081098/flutter_provider)
[](https://codecov.io/gh/hoc081098/flutter_provider)
[](https://opensource.org/licenses/MIT)
[](https://hits.seeyoufarm.com)Flutter generic provider using InheritedWidget. An helper to easily exposes a value using InheritedWidget without having to write one.
## Getting Started
In your flutter project, add the dependency to your `pubspec.yaml`
```yaml
dependencies:
...
flutter_provider:
```## Usage
### 1. Provide
```dart
final foo = Foo();
final bar1 = Bar1();Providers(
providers: [
Provider.value(
bar1,
disposer: (v) => v.dispose(),
),
Provider.factory(
(context) => Bar2(),
disposer: (v) => v.dispose(),
),
],
child: Provider.value(
foo,
disposer: (v) => v.dispose(),
child: const HomePage(),
),
);
```### 2. Consume
```dart
Provider.of(context);
context.get();
Consumer(builder: (context, T value) { });
``````dart
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter provider example'),
),
body: Consumer3(
builder: (BuildContext context, Foo a, Bar1 b, Bar2 c) {
return Container(
constraints: BoxConstraints.expand(),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(a.foo()),
Text(b.bar1()),
Text(c.bar2()),
],
),
),
);
},
),
);
}
}
```# License
MIT License
Copyright (c) 2019-2021 Petrus Nguyễn Thái Học