new: webdav sync test

This commit is contained in:
lollipopkit
2023-12-04 14:21:20 +08:00
parent 2dc86a9da2
commit 38cdef9458
18 changed files with 109 additions and 50 deletions

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io';
import 'package:code_text_field/code_text_field.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_highlight/theme_map.dart';
import 'package:flutter_highlight/themes/a11y-light.dart';
@@ -64,15 +65,25 @@ class _EditorPageState extends State<EditorPage> {
language: Highlights.all[_langCode],
);
/// TODO: This is a temporary solution to avoid the loading stuck
Future.delayed(const Duration(milliseconds: 377)).then((value) async {
if (widget.path != null) {
final code = await File(widget.path!).readAsString();
_controller.text = code;
} else if (widget.text != null) {
_controller.text = widget.text!;
}
});
if (_langCode == null) {
_setupCtrl();
} else {
Future.delayed(const Duration(milliseconds: 377)).then(
(value) async => await _setupCtrl(),
);
}
}
Future<void> _setupCtrl() async {
if (widget.path != null) {
final code = await compute(
(path) async => await File(path).readAsString(),
widget.path!,
);
_controller.text = code;
} else if (widget.text != null) {
_controller.text = widget.text!;
}
}
@override