release 1.0.1: add check widget if mounted when setState

master
Jpeng 5 years ago
parent 32547e8642
commit e8667fb5c5

@ -4,3 +4,6 @@
## 1.0.0 ## 1.0.0
* init release * init release
## 1.0.1
* add check mounted when setState

@ -7,14 +7,14 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.0" version: "2.3.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.4" version: "1.0.5"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
@ -47,7 +47,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "1.0.0" version: "1.0.1"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -66,28 +66,28 @@ packages:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.6" version: "1.1.7"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.6.2" version: "1.6.4"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
name: pedantic name: pedantic
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.7.0" version: "1.8.0+1"
quiver: quiver:
dependency: transitive dependency: transitive
description: description:
name: quiver name: quiver
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.3" version: "2.0.5"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -120,7 +120,7 @@ packages:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.4" version: "1.0.5"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:

@ -102,7 +102,7 @@ class GifImageState extends State<GifImage>{
int _curIndex = 0; int _curIndex = 0;
bool _fetchComplete= false; bool _fetchComplete= false;
ImageInfo get _imageInfo { ImageInfo get _imageInfo {
if(!_fetchComplete)return null; if(!_fetchComplete)return null;
return _infos==null?null:_infos[_curIndex]; return _infos==null?null:_infos[_curIndex];
} }
@ -125,14 +125,15 @@ class GifImageState extends State<GifImage>{
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (widget.image != oldWidget.image) { if (widget.image != oldWidget.image) {
fetchGif(widget.image).then((imageInfors){ fetchGif(widget.image).then((imageInfors){
setState(() { if(mounted)
_infos = imageInfors; setState(() {
_fetchComplete=true; _infos = imageInfors;
_curIndex = widget.controller.value.toInt(); _fetchComplete=true;
if(widget.onFetchCompleted!=null){ _curIndex = widget.controller.value.toInt();
widget.onFetchCompleted(); if(widget.onFetchCompleted!=null){
} widget.onFetchCompleted();
}); }
});
}); });
} }
if (widget.controller != oldWidget.controller) { if (widget.controller != oldWidget.controller) {
@ -143,9 +144,10 @@ class GifImageState extends State<GifImage>{
void _listener(){ void _listener(){
if(_curIndex!=widget.controller.value&&_fetchComplete){ if(_curIndex!=widget.controller.value&&_fetchComplete){
setState(() { if(mounted)
_curIndex = widget.controller.value.toInt(); setState(() {
}); _curIndex = widget.controller.value.toInt();
});
} }
} }
@ -154,14 +156,15 @@ class GifImageState extends State<GifImage>{
super.didChangeDependencies(); super.didChangeDependencies();
if(_infos==null){ if(_infos==null){
fetchGif(widget.image).then((imageInfors){ fetchGif(widget.image).then((imageInfors){
setState(() { if(mounted)
_infos = imageInfors; setState(() {
_fetchComplete=true; _infos = imageInfors;
_curIndex = widget.controller.value.toInt(); _fetchComplete=true;
if(widget.onFetchCompleted!=null){ _curIndex = widget.controller.value.toInt();
widget.onFetchCompleted(); if(widget.onFetchCompleted!=null){
} widget.onFetchCompleted();
}); }
});
}); });
} }
} }

@ -19,7 +19,7 @@ packages:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.6" version: "1.1.7"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter

@ -1,6 +1,6 @@
name: flutter_gifimage name: flutter_gifimage
description: a gifimage for flutter,for solving gif cannot be controlled speed,progress description: a gifimage for flutter,for solving gif cannot be controlled speed,progress
version: 1.0.0 version: 1.0.1
author: Jpeng <peng8350@gmail.com> author: Jpeng <peng8350@gmail.com>
homepage: https://github.com/peng8350/flutter_gifimage homepage: https://github.com/peng8350/flutter_gifimage

Loading…
Cancel
Save