浏览代码

Update cached copy of files when widget is udpated

Vishnu Mohandas 4 年之前
父节点
当前提交
33fd8f8668
共有 1 个文件被更改,包括 11 次插入0 次删除
  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) {