git-touch-android-ios-app/lib/providers/notification.dart

53 lines
1.2 KiB
Dart
Raw Normal View History

2019-01-31 15:07:52 +01:00
import 'package:flutter/material.dart';
2019-01-31 15:07:52 +01:00
class NotificationProvider extends StatefulWidget {
final Widget child;
2019-01-31 15:07:52 +01:00
NotificationProvider({@required this.child});
2019-01-31 15:07:52 +01:00
static _NotificationProviderState of(BuildContext context) {
return (context.inheritFromWidgetOfExactType(_InheritedNotificationProvider)
as _InheritedNotificationProvider)
.data;
}
@override
_NotificationProviderState createState() => new _NotificationProviderState();
}
class _NotificationProviderState extends State<NotificationProvider> {
int count = 0;
@override
void initState() {
super.initState();
}
void setCount(int value) {
setState(() {
count = value;
});
}
2019-01-31 15:07:52 +01:00
@override
Widget build(BuildContext context) {
return new _InheritedNotificationProvider(
data: this,
child: widget.child,
);
}
}
2019-01-31 15:07:52 +01:00
class _InheritedNotificationProvider extends InheritedWidget {
final _NotificationProviderState data;
2019-01-31 15:07:52 +01:00
_InheritedNotificationProvider({
Key key,
2019-01-31 15:07:52 +01:00
@required this.data,
@required Widget child,
}) : super(key: key, child: child);
@override
2019-01-31 15:07:52 +01:00
bool updateShouldNotify(_InheritedNotificationProvider old) => true;
}