withGUI method

Future<Map<String, Future<ImportResult>>?> withGUI(
  1. {String fileExtension = 'fmtc',
  2. bool emptyCacheBeforePicking = true,
  3. FutureOr<bool> collisionHandler(
    1. String filename,
    2. String storeName

Import store files with the platform specifc file picker interface

Where supported, the user will only be able to pick files with the fileExtension extension ('fmtc' by default). If not supported, any file can be picked, but only those with the fileExtension extension will be processed.

Disabling emptyCacheBeforePicking is not recommended (defaults to true). When disabled, the picker may use cached files as opposed to the real files, which may yield unexpected results. This is only effective on Android and iOS - other platforms cannot use caching.

Setting collisionHandler allows for custom behaviour in the event that a store with the same name already exists. If it returns true, the store will be overwritten, otherwise (and by default) the import will fail.

Returns a Map of the input filename to its corresponding ImportResult.


Future<Map<String, Future<ImportResult>>?> withGUI({
  String fileExtension = 'fmtc',
  bool emptyCacheBeforePicking = true,
  FutureOr<bool> Function(String filename, String storeName)?
}) async {
  if (emptyCacheBeforePicking && (Platform.isAndroid || Platform.isIOS)) {
    await FilePicker.platform.clearTemporaryFiles();

  late final FilePickerResult? importPaths;
  try {
    importPaths = await FilePicker.platform.pickFiles(
      dialogTitle: 'Import Cache Stores',
      type: FileType.custom,
      allowedExtensions: [fileExtension],
      allowMultiple: true,
  } on PlatformException catch (_) {
    importPaths = await FilePicker.platform.pickFiles(
      dialogTitle: 'Import Cache Stores',
      allowMultiple: true,

  final files = importPaths?.files.where((f) => f.extension == fileExtension);
  if (files == null || files.isEmpty) return null;
  return manual(
    files.map((e) => File(e.path!)).toList(),
    collisionHandler: collisionHandler,