fix: 安卓全屏(状态栏/导航栏区域融入界面)+ 保存/导出对话框按类型区分后缀并记忆目录
- 全屏:移除全局 SafeArea,系统栏透明;工具栏/底部状态栏底色延伸填满状态栏与导航栏区域,图标亮度随深浅主题切换(桌面端 padding 为 0 无影响) - 文件对话框:保存/导出按类型区分——工程 .seq.json、导出 .svg / .png(默认名=项目名,目录列表只显示对应后缀文件,输入自动补全/替换后缀) - 路径体验:默认目录改为桌面(移动端为应用目录),并跨会话记忆上次使用的目录;此修复同时作用于 Windows exe 与安卓版
This commit is contained in:
+16
-11
@@ -25,15 +25,9 @@ import 'ui/app_shell.dart';
|
|||||||
/// 然后启动根组件 [SequenceDiagramApp]。
|
/// 然后启动根组件 [SequenceDiagramApp]。
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
// 移动端:沉浸式(edge-to-edge)显示,配合 SafeArea 自动避让系统栏。
|
// 移动端:沉浸式(edge-to-edge)显示,系统栏区域由应用工具栏/状态栏底色填充。
|
||||||
if (Platform.isAndroid || Platform.isIOS) {
|
if (Platform.isAndroid || Platform.isIOS) {
|
||||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
|
||||||
statusBarColor: Colors.transparent,
|
|
||||||
systemNavigationBarColor: Colors.transparent,
|
|
||||||
statusBarIconBrightness: Brightness.dark,
|
|
||||||
statusBarBrightness: Brightness.light,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
await Storage.instance.init();
|
await Storage.instance.init();
|
||||||
runApp(const SequenceDiagramApp());
|
runApp(const SequenceDiagramApp());
|
||||||
@@ -170,14 +164,25 @@ class _SequenceDiagramAppState extends State<SequenceDiagramApp> {
|
|||||||
title: '时序图设计器 · Sequence Diagram Studio',
|
title: '时序图设计器 · Sequence Diagram Studio',
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: buildTheme(tokens),
|
theme: buildTheme(tokens),
|
||||||
// 固定文本缩放并包裹 SafeArea:保证平板等分辨率下布局像素级精准,
|
// 固定文本缩放;系统栏图标随主题亮度自动切换(透明系统栏,
|
||||||
// 不受系统字体缩放影响,并自动避让状态栏 / 导航栏。
|
// 状态栏 / 导航栏区域由 AppShell 的工具栏 / 状态栏底色填满)。
|
||||||
builder: (BuildContext context, Widget? child) {
|
builder: (BuildContext context, Widget? child) {
|
||||||
return MediaQuery(
|
final bool dark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
|
value: SystemUiOverlayStyle(
|
||||||
|
statusBarColor: Colors.transparent,
|
||||||
|
statusBarIconBrightness: dark ? Brightness.light : Brightness.dark,
|
||||||
|
statusBarBrightness: dark ? Brightness.dark : Brightness.light,
|
||||||
|
systemNavigationBarColor: Colors.transparent,
|
||||||
|
systemNavigationBarIconBrightness: dark ? Brightness.light : Brightness.dark,
|
||||||
|
systemNavigationBarDividerColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
child: MediaQuery(
|
||||||
data: MediaQuery.of(context).copyWith(
|
data: MediaQuery.of(context).copyWith(
|
||||||
textScaler: const TextScaler.linear(1.0),
|
textScaler: const TextScaler.linear(1.0),
|
||||||
),
|
),
|
||||||
child: SafeArea(child: child ?? const SizedBox.shrink()),
|
child: child ?? const SizedBox.shrink(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
home: AppShell(controller: _controller),
|
home: AppShell(controller: _controller),
|
||||||
|
|||||||
+36
-13
@@ -171,7 +171,13 @@ class _AppShellState extends State<AppShell> {
|
|||||||
|
|
||||||
/// 另存为:选择目标路径后写入文件(同时生成 .bak 备份)。
|
/// 另存为:选择目标路径后写入文件(同时生成 .bak 备份)。
|
||||||
Future<void> _saveAs() async {
|
Future<void> _saveAs() async {
|
||||||
final String? path = await pickFile(context, save: true, initialPath: c.filePath);
|
final String? path = await pickFile(
|
||||||
|
context,
|
||||||
|
save: true,
|
||||||
|
initialPath: c.filePath,
|
||||||
|
defaultName: c.filePath == null ? '${c.project.name}.seq.json' : null,
|
||||||
|
suffix: '.seq.json',
|
||||||
|
);
|
||||||
if (path == null) return;
|
if (path == null) return;
|
||||||
try {
|
try {
|
||||||
await c.saveAs(path);
|
await c.saveAs(path);
|
||||||
@@ -187,17 +193,21 @@ class _AppShellState extends State<AppShell> {
|
|||||||
if (mounted) await showMessage(context, '未授权', '未检测到有效授权(license/*.lic),无法导出 SVG。');
|
if (mounted) await showMessage(context, '未授权', '未检测到有效授权(license/*.lic),无法导出 SVG。');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String? path = await pickFile(context, save: true, initialPath: c.filePath);
|
final String? path = await pickFile(
|
||||||
|
context,
|
||||||
|
save: true,
|
||||||
|
defaultName: '${c.project.name}.svg',
|
||||||
|
suffix: '.svg',
|
||||||
|
);
|
||||||
if (path == null) return;
|
if (path == null) return;
|
||||||
final String svgPath = path.replaceAll(RegExp(r'\.json$'), '.svg');
|
|
||||||
try {
|
try {
|
||||||
final String svg = SvgWriter(
|
final String svg = SvgWriter(
|
||||||
project: c.project,
|
project: c.project,
|
||||||
tokens: Tokens.of(c.brightness),
|
tokens: Tokens.of(c.brightness),
|
||||||
mode: c.project.viewState.mode,
|
mode: c.project.viewState.mode,
|
||||||
).build();
|
).build();
|
||||||
await File(svgPath).writeAsString(svg, flush: true);
|
await File(path).writeAsString(svg, flush: true);
|
||||||
if (mounted) c.setStatus('已导出 $svgPath');
|
if (mounted) c.setStatus('已导出 $path');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) await showMessage(context, '导出失败', '$e');
|
if (mounted) await showMessage(context, '导出失败', '$e');
|
||||||
}
|
}
|
||||||
@@ -210,17 +220,21 @@ class _AppShellState extends State<AppShell> {
|
|||||||
if (mounted) await showMessage(context, '未授权', '未检测到有效授权(license/*.lic),无法导出 PNG。');
|
if (mounted) await showMessage(context, '未授权', '未检测到有效授权(license/*.lic),无法导出 PNG。');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String? path = await pickFile(context, save: true, initialPath: c.filePath);
|
final String? path = await pickFile(
|
||||||
|
context,
|
||||||
|
save: true,
|
||||||
|
defaultName: '${c.project.name}.png',
|
||||||
|
suffix: '.png',
|
||||||
|
);
|
||||||
if (path == null) return;
|
if (path == null) return;
|
||||||
final String pngPath = path.replaceAll(RegExp(r'\.(json|svg)$'), '.png');
|
|
||||||
try {
|
try {
|
||||||
// 抓取画布舞台的渲染对象并转换为图像。
|
// 抓取画布舞台的渲染对象并转换为图像。
|
||||||
final RenderRepaintBoundary boundary =
|
final RenderRepaintBoundary boundary =
|
||||||
_stageKey.currentContext!.findRenderObject()! as RenderRepaintBoundary;
|
_stageKey.currentContext!.findRenderObject()! as RenderRepaintBoundary;
|
||||||
final ui.Image image = await boundary.toImage(pixelRatio: 2);
|
final ui.Image image = await boundary.toImage(pixelRatio: 2);
|
||||||
final ByteData? data = await image.toByteData(format: ui.ImageByteFormat.png);
|
final ByteData? data = await image.toByteData(format: ui.ImageByteFormat.png);
|
||||||
await File(pngPath).writeAsBytes(data!.buffer.asUint8List(), flush: true);
|
await File(path).writeAsBytes(data!.buffer.asUint8List(), flush: true);
|
||||||
if (mounted) c.setStatus('已导出 $pngPath');
|
if (mounted) c.setStatus('已导出 $path');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) await showMessage(context, '导出失败', '$e');
|
if (mounted) await showMessage(context, '导出失败', '$e');
|
||||||
}
|
}
|
||||||
@@ -256,8 +270,13 @@ class _AppShellState extends State<AppShell> {
|
|||||||
backgroundColor: t.bg,
|
backgroundColor: t.bg,
|
||||||
body: Column(
|
body: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
// 顶部:自适应工具栏。
|
// 顶部:系统状态栏区域与工具栏同底色,内容在系统栏下方,
|
||||||
_toolbar(t),
|
// 移动端实现真正的全屏(无黑边),桌面端 padding 为 0 无影响。
|
||||||
|
Container(
|
||||||
|
color: t.chrome,
|
||||||
|
padding: EdgeInsets.only(top: MediaQuery.paddingOf(context).top),
|
||||||
|
child: _toolbar(t),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: Row(
|
||||||
// 拉伸交叉轴:保证左右侧栏始终从工具栏一直贯通到底部状态栏。
|
// 拉伸交叉轴:保证左右侧栏始终从工具栏一直贯通到底部状态栏。
|
||||||
@@ -319,8 +338,12 @@ class _AppShellState extends State<AppShell> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// 底部:状态栏。
|
// 底部:系统导航栏区域与状态栏同底色,内容在系统栏上方。
|
||||||
_statusBar(t),
|
Container(
|
||||||
|
color: t.chrome,
|
||||||
|
padding: EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom),
|
||||||
|
child: _statusBar(t),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
+109
-25
@@ -14,6 +14,7 @@ import 'package:flutter/material.dart' hide Action;
|
|||||||
import '../license/license_service.dart';
|
import '../license/license_service.dart';
|
||||||
import '../model/models.dart';
|
import '../model/models.dart';
|
||||||
import '../model/units.dart';
|
import '../model/units.dart';
|
||||||
|
import '../persistence/storage.dart';
|
||||||
import '../state/app_controller.dart';
|
import '../state/app_controller.dart';
|
||||||
import '../theme/tokens.dart';
|
import '../theme/tokens.dart';
|
||||||
|
|
||||||
@@ -66,15 +67,27 @@ Future<void> showMessage(BuildContext context, String title, String message) {
|
|||||||
|
|
||||||
// ===================== 文件浏览 / 保存对话框 =====================
|
// ===================== 文件浏览 / 保存对话框 =====================
|
||||||
|
|
||||||
/// 文件浏览对话框:用于打开或另存为 `.seq.json` 文件。
|
/// 文件浏览对话框:用于打开或另存为文件(工程 `.seq.json`、导出 `.svg` / `.png`)。
|
||||||
/// [saveMode] 为 true 时进入保存流程,否则为打开流程。
|
///
|
||||||
|
/// [saveMode] 为 true 时进入保存流程,否则为打开流程;[suffix] 决定文件过滤
|
||||||
|
/// 与保存时自动补全的后缀;[defaultName] 为保存模式的默认文件名。
|
||||||
class FileBrowserDialog extends StatefulWidget {
|
class FileBrowserDialog extends StatefulWidget {
|
||||||
const FileBrowserDialog({super.key, required this.saveMode, this.initialPath});
|
const FileBrowserDialog({
|
||||||
|
super.key,
|
||||||
|
required this.saveMode,
|
||||||
|
this.initialPath,
|
||||||
|
this.defaultName,
|
||||||
|
this.suffix = '.seq.json',
|
||||||
|
});
|
||||||
|
|
||||||
/// 是否为保存模式(true = 另存为,false = 打开)。
|
/// 是否为保存模式(true = 另存为,false = 打开)。
|
||||||
final bool saveMode;
|
final bool saveMode;
|
||||||
/// 初始目录或初始文件路径。
|
/// 初始目录或初始文件路径。
|
||||||
final String? initialPath;
|
final String? initialPath;
|
||||||
|
/// 保存模式的默认文件名(如 `装配线节拍.svg`)。
|
||||||
|
final String? defaultName;
|
||||||
|
/// 文件后缀:过滤目录列表并自动补全用户输入(如 `.svg` / `.png` / `.seq.json`)。
|
||||||
|
final String suffix;
|
||||||
|
|
||||||
/// 创建文件浏览对话框对应的状态对象。
|
/// 创建文件浏览对话框对应的状态对象。
|
||||||
@override
|
@override
|
||||||
@@ -87,43 +100,97 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
|||||||
late Directory _dir;
|
late Directory _dir;
|
||||||
/// 文件名输入控制器。
|
/// 文件名输入控制器。
|
||||||
late TextEditingController _name;
|
late TextEditingController _name;
|
||||||
/// 当前目录下的条目(子目录 + .json 文件)。
|
/// 当前目录下的条目(子目录 + 匹配后缀的文件)。
|
||||||
List<FileSystemEntity> _entries = <FileSystemEntity>[];
|
List<FileSystemEntity> _entries = <FileSystemEntity>[];
|
||||||
/// 读取目录失败时的错误信息。
|
/// 读取目录失败时的错误信息。
|
||||||
String? _error;
|
String? _error;
|
||||||
|
|
||||||
/// 解析初始路径、初始化文件名,并首次刷新目录列表。
|
/// 解析初始路径 / 上次目录 / 桌面,初始化文件名并刷新目录列表。
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
String start = widget.initialPath ?? '';
|
final String base = widget.defaultName ??
|
||||||
if (start.isEmpty) {
|
(widget.initialPath != null && widget.initialPath!.isNotEmpty
|
||||||
// 桌面版从用户目录开始;Android/iOS 从应用可写目录(系统临时目录)开始。
|
? widget.initialPath!.split(RegExp(r'[\\/]')).last
|
||||||
|
: '节拍方案${widget.suffix}');
|
||||||
|
_name = TextEditingController(text: base);
|
||||||
|
_bootstrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 异步确定起始目录:优先初始路径 → 上次使用的目录 → 桌面 → 用户目录。
|
||||||
|
Future<void> _bootstrap() async {
|
||||||
|
String start = '';
|
||||||
|
if (widget.initialPath != null && widget.initialPath!.isNotEmpty) {
|
||||||
|
final File f = File(widget.initialPath!);
|
||||||
|
start = await f.exists() ? f.parent.path : widget.initialPath!;
|
||||||
|
}
|
||||||
|
if (start.isEmpty || !Directory(start).existsSync()) {
|
||||||
|
start = await _readLastDir();
|
||||||
|
}
|
||||||
|
if (start.isEmpty || !Directory(start).existsSync()) {
|
||||||
|
final Directory? desktop = _desktop();
|
||||||
|
if (desktop != null) {
|
||||||
|
start = desktop.path;
|
||||||
|
} else {
|
||||||
start = Platform.environment['USERPROFILE'] ??
|
start = Platform.environment['USERPROFILE'] ??
|
||||||
(Platform.isAndroid || Platform.isIOS
|
(Platform.isAndroid || Platform.isIOS
|
||||||
? Directory.systemTemp.path
|
? Directory.systemTemp.path
|
||||||
: Directory.current.path);
|
: Directory.current.path);
|
||||||
}
|
}
|
||||||
if (File(start).existsSync()) {
|
|
||||||
start = File(start).parent.path;
|
|
||||||
}
|
}
|
||||||
_dir = Directory(start);
|
_dir = Directory(start);
|
||||||
if (!_dir.existsSync()) _dir = Directory.current;
|
if (!_dir.existsSync()) _dir = Directory.current;
|
||||||
final String base = widget.initialPath != null && widget.initialPath!.isNotEmpty
|
if (mounted) _refresh();
|
||||||
? widget.initialPath!.split(RegExp(r'[\\/]')).last
|
|
||||||
: '节拍方案.seq.json';
|
|
||||||
_name = TextEditingController(text: base);
|
|
||||||
_refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 重新读取当前目录:仅保留子目录与 .json 文件,
|
/// 上次使用目录的持久化文件路径(位于应用数据目录,跨会话记忆)。
|
||||||
|
File get _lastDirFile => File(
|
||||||
|
'${Storage.instance.appDir.path}${Platform.pathSeparator}last_dir.txt');
|
||||||
|
|
||||||
|
/// 读取上次使用的目录;不存在或不可用时返回空串。
|
||||||
|
Future<String> _readLastDir() async {
|
||||||
|
try {
|
||||||
|
final File f = _lastDirFile;
|
||||||
|
if (await f.exists()) {
|
||||||
|
final String s = (await f.readAsString()).trim();
|
||||||
|
if (s.isNotEmpty && Directory(s).existsSync()) return s;
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 记住本次使用的目录,便于下次直接定位。
|
||||||
|
Future<void> _writeLastDir(String path) async {
|
||||||
|
try {
|
||||||
|
final File f = _lastDirFile;
|
||||||
|
await f.parent.create(recursive: true);
|
||||||
|
await f.writeAsString(path, flush: true);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 规范化文件名:替换其它已知后缀并补全目标后缀。
|
||||||
|
String _ensureSuffix(String raw) {
|
||||||
|
String n = raw.trim();
|
||||||
|
if (n.isEmpty) return n;
|
||||||
|
const List<String> known = <String>['.seq.json', '.json', '.svg', '.png'];
|
||||||
|
for (final String k in known) {
|
||||||
|
if (n.toLowerCase().endsWith(k)) {
|
||||||
|
if (k == widget.suffix) return n;
|
||||||
|
n = n.substring(0, n.length - k.length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '$n${widget.suffix}';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 重新读取当前目录:仅保留子目录与匹配后缀的文件,
|
||||||
/// 目录排在文件之前并按名称不区分大小写排序。
|
/// 目录排在文件之前并按名称不区分大小写排序。
|
||||||
void _refresh() {
|
void _refresh() {
|
||||||
try {
|
try {
|
||||||
final List<FileSystemEntity> all = _dir.listSync();
|
final List<FileSystemEntity> all = _dir.listSync();
|
||||||
_entries = all.where((FileSystemEntity e) {
|
_entries = all.where((FileSystemEntity e) {
|
||||||
if (e is Directory) return true;
|
if (e is Directory) return true;
|
||||||
return e.path.toLowerCase().endsWith('.json');
|
return e.path.toLowerCase().endsWith(widget.suffix.toLowerCase());
|
||||||
}).toList()
|
}).toList()
|
||||||
..sort((FileSystemEntity a, FileSystemEntity b) {
|
..sort((FileSystemEntity a, FileSystemEntity b) {
|
||||||
final bool ad = a is Directory;
|
final bool ad = a is Directory;
|
||||||
@@ -188,7 +255,7 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(widget.saveMode ? '另存为 .seq.json' : '打开 .seq.json',
|
Text(widget.saveMode ? '保存 ${widget.suffix} 文件' : '打开 ${widget.suffix} 文件',
|
||||||
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w700, color: t.text)),
|
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w700, color: t.text)),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Row(
|
Row(
|
||||||
@@ -283,7 +350,7 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
|||||||
const Divider(),
|
const Divider(),
|
||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text('文件名', style: TextStyle(color: t.sub, fontSize: 11)),
|
Text('文件名(${widget.suffix})', style: TextStyle(color: t.sub, fontSize: 11)),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
@@ -293,6 +360,8 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
|||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: t.panel2,
|
fillColor: t.panel2,
|
||||||
|
hintText: '名称${widget.suffix}',
|
||||||
|
hintStyle: TextStyle(color: t.dim, fontSize: 11),
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -307,12 +376,13 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// 规范化文件名:空名忽略,缺少 .json 后缀时补全为 .seq.json。
|
// 规范化文件名:空名忽略;替换其它已知后缀并补全目标后缀。
|
||||||
String name = _name.text.trim();
|
final String name = _ensureSuffix(_name.text);
|
||||||
if (name.isEmpty) return;
|
if (name.isEmpty) return;
|
||||||
if (!name.toLowerCase().endsWith('.json')) name = '$name.seq.json';
|
|
||||||
final String sep = Platform.pathSeparator;
|
final String sep = Platform.pathSeparator;
|
||||||
final String path = '${_dir.path}$sep$name';
|
final String path = '${_dir.path}$sep$name';
|
||||||
|
// 记住本次使用的目录,下次直接定位。
|
||||||
|
_writeLastDir(_dir.path);
|
||||||
Navigator.pop(context, path);
|
Navigator.pop(context, path);
|
||||||
},
|
},
|
||||||
child: Text(widget.saveMode ? '保存' : '打开'),
|
child: Text(widget.saveMode ? '保存' : '打开'),
|
||||||
@@ -327,11 +397,25 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 打开文件选择对话框并返回所选路径;[save] 决定保存或打开模式。
|
/// 打开文件选择对话框并返回所选路径。
|
||||||
Future<String?> pickFile(BuildContext context, {required bool save, String? initialPath}) {
|
///
|
||||||
|
/// [save] 决定保存或打开模式;[suffix] 决定文件过滤与自动补全的后缀
|
||||||
|
/// (`.seq.json` / `.svg` / `.png`);[defaultName] 为保存模式的默认文件名。
|
||||||
|
Future<String?> pickFile(
|
||||||
|
BuildContext context, {
|
||||||
|
required bool save,
|
||||||
|
String? initialPath,
|
||||||
|
String? defaultName,
|
||||||
|
String suffix = '.seq.json',
|
||||||
|
}) {
|
||||||
return showDialog<String>(
|
return showDialog<String>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext ctx) => FileBrowserDialog(saveMode: save, initialPath: initialPath),
|
builder: (BuildContext ctx) => FileBrowserDialog(
|
||||||
|
saveMode: save,
|
||||||
|
initialPath: initialPath,
|
||||||
|
defaultName: defaultName,
|
||||||
|
suffix: suffix,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user