1
0
mirror of https://github.com/GitJournal/GitJournal.git synced 2025-07-23 02:07:26 +08:00

Editors: Implement didUpdateWidget

The parent sometimes changes the noteModified parameter. It's strange
for me that the stateless widgets aren't always rebuilt if their parent
widget's properties change.
This commit is contained in:
Vishesh Handa
2020-05-14 12:49:52 +02:00
parent c9b755862b
commit 79ece901a8
4 changed files with 36 additions and 0 deletions

@ -85,6 +85,15 @@ class ChecklistEditorState extends State<ChecklistEditor>
super.dispose();
}
@override
void didUpdateWidget(ChecklistEditor oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.noteModified != widget.noteModified) {
_noteModified = widget.noteModified;
}
}
UniqueKey _getKey(ChecklistItem item) {
for (var e in keys.entries) {
if (e.value == item) {

@ -68,6 +68,15 @@ class JournalEditorState extends State<JournalEditor> implements EditorState {
super.dispose();
}
@override
void didUpdateWidget(JournalEditor oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.noteModified != widget.noteModified) {
_noteModified = widget.noteModified;
}
}
@override
Widget build(BuildContext context) {
var editor = EditorScrollView(

@ -81,6 +81,15 @@ class MarkdownEditorState extends State<MarkdownEditor> implements EditorState {
super.dispose();
}
@override
void didUpdateWidget(MarkdownEditor oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.noteModified != widget.noteModified) {
_noteModified = widget.noteModified;
}
}
@override
Widget build(BuildContext context) {
var editor = EditorScrollView(

@ -70,6 +70,15 @@ class RawEditorState extends State<RawEditor> implements EditorState {
super.dispose();
}
@override
void didUpdateWidget(RawEditor oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.noteModified != widget.noteModified) {
_noteModified = widget.noteModified;
}
}
@override
Widget build(BuildContext context) {
var editor = EditorScrollView(