mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +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(
|
||||
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:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/core/notes_folder_fs.dart';
|
||||
import 'package:gitjournal/error_reporting.dart';
|
||||
import 'package:share/share.dart';
|
||||
|
||||
@ -99,9 +100,9 @@ Widget buildEditorBottonBar(
|
||||
BuildContext context,
|
||||
Editor editor,
|
||||
EditorState editorState,
|
||||
NotesFolderFS parentFolder,
|
||||
) {
|
||||
var note = editorState.getNote();
|
||||
var folderName = note.parent.pathSpec();
|
||||
var folderName = parentFolder.pathSpec();
|
||||
if (folderName.isEmpty) {
|
||||
folderName = "Root Folder";
|
||||
}
|
||||
|
@ -86,7 +86,8 @@ class JournalEditorState extends State<JournalEditor> implements EditorState {
|
||||
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
||||
body: editor,
|
||||
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,
|
||||
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),
|
||||
body: editor,
|
||||
bottomNavigationBar: Builder(
|
||||
builder: (context) => buildEditorBottonBar(context, widget, this),
|
||||
builder: (context) =>
|
||||
buildEditorBottonBar(context, widget, this, note.parent),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user