bug fix : empty string being saved everytime file info is closed without editing caption
This commit is contained in:
parent
27c660771f
commit
e5125254b2
|
@ -16,7 +16,7 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
|
|||
int currentLength = 0;
|
||||
final _textController = TextEditingController();
|
||||
final _focusNode = FocusNode();
|
||||
String editedCaption = "";
|
||||
String? editedCaption;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -27,12 +27,15 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
|
|||
editedCaption = caption;
|
||||
}
|
||||
});
|
||||
editedCaption = widget.file.caption;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (editedCaption != null) {
|
||||
editFileCaption(null, widget.file, editedCaption);
|
||||
}
|
||||
_textController.dispose();
|
||||
_focusNode.removeListener(() {});
|
||||
super.dispose();
|
||||
|
@ -45,7 +48,9 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
|
|||
final caption = widget.file.caption;
|
||||
return TextField(
|
||||
onEditingComplete: () {
|
||||
if (editedCaption != null) {
|
||||
editFileCaption(context, widget.file, editedCaption);
|
||||
}
|
||||
_focusNode.unfocus();
|
||||
},
|
||||
controller: _textController,
|
||||
|
|
Loading…
Reference in a new issue