mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 10:17:16 +08:00
Avoid mutating the state while building the Editor's bottom bar
getNote() mutates the state
This commit is contained in:
@ -161,7 +161,8 @@ class ChecklistEditorState extends State<ChecklistEditor>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
bottomNavigationBar: Builder(
|
bottomNavigationBar: Builder(
|
||||||
builder: (context) => buildEditorBottonBar(context, widget, this),
|
builder: (context) =>
|
||||||
|
buildEditorBottonBar(context, widget, this, widget.note.parent),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gitjournal/core/note.dart';
|
import 'package:gitjournal/core/note.dart';
|
||||||
|
import 'package:gitjournal/core/notes_folder_fs.dart';
|
||||||
import 'package:gitjournal/error_reporting.dart';
|
import 'package:gitjournal/error_reporting.dart';
|
||||||
import 'package:share/share.dart';
|
import 'package:share/share.dart';
|
||||||
|
|
||||||
@ -99,9 +100,9 @@ Widget buildEditorBottonBar(
|
|||||||
BuildContext context,
|
BuildContext context,
|
||||||
Editor editor,
|
Editor editor,
|
||||||
EditorState editorState,
|
EditorState editorState,
|
||||||
|
NotesFolderFS parentFolder,
|
||||||
) {
|
) {
|
||||||
var note = editorState.getNote();
|
var folderName = parentFolder.pathSpec();
|
||||||
var folderName = note.parent.pathSpec();
|
|
||||||
if (folderName.isEmpty) {
|
if (folderName.isEmpty) {
|
||||||
folderName = "Root Folder";
|
folderName = "Root Folder";
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,8 @@ class JournalEditorState extends State<JournalEditor> implements EditorState {
|
|||||||
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
||||||
body: editor,
|
body: editor,
|
||||||
bottomNavigationBar: Builder(
|
bottomNavigationBar: Builder(
|
||||||
builder: (context) => buildEditorBottonBar(context, widget, this),
|
builder: (context) =>
|
||||||
|
buildEditorBottonBar(context, widget, this, note.parent),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,8 @@ class MarkdownEditorState extends State<MarkdownEditor> implements EditorState {
|
|||||||
),
|
),
|
||||||
body: body,
|
body: body,
|
||||||
bottomNavigationBar: Builder(
|
bottomNavigationBar: Builder(
|
||||||
builder: (context) => buildEditorBottonBar(context, widget, this),
|
builder: (context) =>
|
||||||
|
buildEditorBottonBar(context, widget, this, note.parent),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,8 @@ class RawEditorState extends State<RawEditor> implements EditorState {
|
|||||||
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
||||||
body: editor,
|
body: editor,
|
||||||
bottomNavigationBar: Builder(
|
bottomNavigationBar: Builder(
|
||||||
builder: (context) => buildEditorBottonBar(context, widget, this),
|
builder: (context) =>
|
||||||
|
buildEditorBottonBar(context, widget, this, note.parent),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user