
setState가 너무 빨리 사라져서 에러가 납니다. 앞에 await붙이면 또 에러납니다. Future써야 한다면 중간에 코드 다 갈아 엎고 새로 작성해야 할까요... 위젯빌드 부분이요..
setState() called after dispose(): _UploadState#355fe(lifecycle state: defunct, not mounted)
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose()
타이머 넣어봤는데도 안됩니다.. 마운트를 체크하라고하는데 잘 모르겠습니다.
onPressed: () async{
Navigator.of(context).pop();
Uint8List file = await pickImage(ImageSource.gallery);
if (this.mounted) {
setState(() {
file1=file;
});
}
await Image.memory(file1!);},로 수정했는데 이젠 이미지파일이 안보이네요..-_-;;;;isNotEmpty나 hasData로 조건문 쓰고 싶은데 앞에 뭐쓰고 점찍어야 하는지 몰겠습니다. 예)if(file.isNotEmpty)