provider 1.3.0 provider: ^1.3.0 copied to clipboard
An helper to easily exposes a value using InheritedWidget without having to write one.
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Provider(
value: 42,
child: Example(),
);
}
}
class Example extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text(Provider.of<int>(context).toString());
}
}