improve code editor

This commit is contained in:
2025-01-22 22:02:16 +08:00
parent 87f0f5bb55
commit 8e2520f8e8
2 changed files with 7 additions and 4 deletions

View File

@@ -298,10 +298,10 @@ class _BodyState extends State<_Body> {
//
}
}
context.to(() => _EditFilePage(source.filePath)).then((value) async {
context.to(() => _EditFilePage(source.filePath, () async {
await ComicSource.reload();
setState(() {});
});
}));
}
static Future<void> update(ComicSource source) async {
@@ -617,10 +617,12 @@ void _addAllPagesWithComicSource(ComicSource source) {
}
class _EditFilePage extends StatefulWidget {
const _EditFilePage(this.path);
const _EditFilePage(this.path, this.onExit);
final String path;
final void Function() onExit;
@override
State<_EditFilePage> createState() => __EditFilePageState();
}
@@ -637,6 +639,7 @@ class __EditFilePageState extends State<_EditFilePage> {
@override
void dispose() {
File(widget.path).writeAsStringSync(current);
widget.onExit();
super.dispose();
}