Ver Fonte

Update cached copy of files when widget is udpated

Vishnu Mohandas há 4 anos atrás
pai
commit
33fd8f8668
1 ficheiros alterados com 11 adições e 0 exclusões
  1. 11 0
      lib/ui/huge_listview/lazy_loading_gallery.dart

+ 11 - 0
lib/ui/huge_listview/lazy_loading_gallery.dart

@@ -73,6 +73,17 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
     super.dispose();
   }
 
+  @override
+  void didUpdateWidget(LazyLoadingGallery oldWidget) {
+    super.didUpdateWidget(oldWidget);
+    if (widget.files.isEmpty ||
+        widget.files[0].creationTime != _files[0].creationTime) {
+      setState(() {
+        _files = widget.files;
+      });
+    }
+  }
+
   @override
   Widget build(BuildContext context) {
     if (_files.length == 0) {