Skip to content

Commit

Permalink
- Added auto-dismissal in-app notification #16
Browse files Browse the repository at this point in the history
  • Loading branch information
5hirish committed Aug 5, 2023
1 parent fb6df25 commit aaded52
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class WindowPage extends HookConsumerWidget {
class InAppNotificationWidget extends HookConsumerWidget {
const InAppNotificationWidget({Key? key}) : super(key: key);

static const Duration notificationDismissDuration = Duration(seconds: 5);

@override
Widget build(BuildContext context, WidgetRef ref) {
final notification = ref.watch(inAppNotificationStateProvider);
Expand All @@ -104,6 +106,13 @@ class InAppNotificationWidget extends HookConsumerWidget {
final controller =
useAnimationController(duration: const Duration(seconds: 2));

useEffect(() {
Future.delayed(notificationDismissDuration, () {
ref.invalidate(inAppNotificationStateProvider);
});
return null;
}, const []);

return Dismissible(
key: const Key("notification"),
onDismissed: (DismissDirection direction) {
Expand Down

0 comments on commit aaded52

Please sign in to comment.