feat(flows): native file dialog for flow file inputs
Some checks failed
Security / Security check (push) Failing after 2s
Some checks failed
Security / Security check (push) Failing after 2s
Wires the editor's new onPickFile host callback to file_picker (withData: the editor receives name + bytes, never a raw path). Pins chain_studio_flow_editor to v0.23.0. No more typing absolute paths to feed a flow a file. Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
parent
065939be74
commit
adb8d3f914
3 changed files with 17 additions and 2 deletions
|
|
@ -11,6 +11,7 @@
|
|||
// need to know what's inside the editor any more.
|
||||
|
||||
import 'package:chain_studio_flow_editor/chain_studio_flow_editor.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/error_presentation.dart';
|
||||
|
|
@ -95,6 +96,17 @@ class _FlowsPageState extends State<FlowsPage> {
|
|||
/// Hub's install API and returns the refreshed capability
|
||||
/// list so the editor can re-analyze without waiting for the
|
||||
/// parent widget rebuild.
|
||||
/// Native picker for a flow file input. `withData` loads the
|
||||
/// bytes directly so the editor never touches the path itself
|
||||
/// (sandbox-friendly: the picker grants access to exactly the
|
||||
/// chosen file).
|
||||
Future<PickedFileData?> _pickFlowInputFile() async {
|
||||
final picked = await FilePicker.pickFiles(withData: true);
|
||||
final f = picked?.files.single;
|
||||
if (f == null || f.bytes == null) return null;
|
||||
return PickedFileData(fileName: f.name, bytes: f.bytes!);
|
||||
}
|
||||
|
||||
Future<List<String>?> _onInstallCapability(String capability) async {
|
||||
// The analyzer hands us the full `use:` value (e.g. `debug.echo@^0`).
|
||||
// The hub resolves install sources by bare capability name; the
|
||||
|
|
@ -167,6 +179,9 @@ class _FlowsPageState extends State<FlowsPage> {
|
|||
onInstallCapability: _onInstallCapability,
|
||||
onAddModuleSource: _onAddModuleSource,
|
||||
activeProject: Workspace.instance.activeSlug,
|
||||
// Native file dialog for the Run tab's file inputs —
|
||||
// nobody should have to type an absolute path by hand.
|
||||
onPickFile: _pickFlowInputFile,
|
||||
// The file wins for the run; accepting the switch only
|
||||
// aligns the workspace view to the file's project.
|
||||
onSwitchToFileProject: (slug) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue