Update device folder page on event
This commit is contained in:
parent
2a312c5015
commit
e5c698b7b4
1 changed files with 20 additions and 0 deletions
|
@ -1,6 +1,10 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:photos/core/event_bus.dart';
|
||||
import 'package:photos/db/photo_db.dart';
|
||||
import 'package:photos/events/local_photos_updated_event.dart';
|
||||
import 'package:photos/favorite_photos_repository.dart';
|
||||
import 'package:photos/models/device_folder.dart';
|
||||
import 'package:photos/models/filters/favorite_items_filter.dart';
|
||||
|
@ -19,6 +23,16 @@ class DeviceFolderGalleryWidget extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _DeviceFolderGalleryWidgetState extends State<DeviceFolderGalleryWidget> {
|
||||
StreamSubscription<LocalPhotosUpdatedEvent> _subscription;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_subscription = Bus.instance.on<LocalPhotosUpdatedEvent>().listen((event) {
|
||||
setState(() {});
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
|
@ -107,4 +121,10 @@ class _DeviceFolderGalleryWidgetState extends State<DeviceFolderGalleryWidget> {
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_subscription.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue