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;
|
int currentLength = 0;
|
||||||
final _textController = TextEditingController();
|
final _textController = TextEditingController();
|
||||||
final _focusNode = FocusNode();
|
final _focusNode = FocusNode();
|
||||||
String editedCaption = "";
|
String? editedCaption;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -27,12 +27,15 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
|
||||||
editedCaption = caption;
|
editedCaption = caption;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
editedCaption = widget.file.caption;
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
if (editedCaption != null) {
|
||||||
editFileCaption(null, widget.file, editedCaption);
|
editFileCaption(null, widget.file, editedCaption);
|
||||||
|
}
|
||||||
_textController.dispose();
|
_textController.dispose();
|
||||||
_focusNode.removeListener(() {});
|
_focusNode.removeListener(() {});
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
@ -45,7 +48,9 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
|
||||||
final caption = widget.file.caption;
|
final caption = widget.file.caption;
|
||||||
return TextField(
|
return TextField(
|
||||||
onEditingComplete: () {
|
onEditingComplete: () {
|
||||||
|
if (editedCaption != null) {
|
||||||
editFileCaption(context, widget.file, editedCaption);
|
editFileCaption(context, widget.file, editedCaption);
|
||||||
|
}
|
||||||
_focusNode.unfocus();
|
_focusNode.unfocus();
|
||||||
},
|
},
|
||||||
controller: _textController,
|
controller: _textController,
|
||||||
|
|
Loading…
Reference in a new issue