Skip to content

[file_selector_windows] The initial directory does not work after completing a file selection #102706

@tgalpha

Description

@tgalpha

Steps to Reproduce

  1. Execute flutter run on the code sample on windows
  2. Click the openfile button to select a file that is not in the initialDirectory
  3. Click any button again

Expected results:
Open a dialog whose initial directory is initialDirectory

Actual results:
Open a dialog whose initial directory is the last selected file directory

Code sample
import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String initialDirectory = normalize(absolute('.'));

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Text('initialDirectory: $initialDirectory'),
          ElevatedButton(
            onPressed: () => openFile(initialDirectory: initialDirectory),
            child: const Text('openFile'),
          ),
          ElevatedButton(
            onPressed: () => openFiles(initialDirectory: initialDirectory),
            child: const Text('openFiles'),
          ),
          ElevatedButton(
            onPressed: () => getSavePath(initialDirectory: initialDirectory),
            child: const Text('getSavePath'),
          ),
          ElevatedButton(
            onPressed: () => getDirectoryPath(initialDirectory: initialDirectory),
            child: const Text('getDirectoryPath'),
          ),
        ],
      ),
    );
  }
}
Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: file_selectorThe file_selector pluginpackageflutter/packages repository. See also p: labels.platform-windowsBuilding on or for Windows specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions