Directory picker in Flutter con file_picker

Mattepuffo's logo
Directory picker in Flutter con file_picker

Directory picker in Flutter con file_picker

file_picker è una libreria per Flutter che ci consente di scegliere un o più files, o anche una directory.

Che è il caso che vedremo noi.

In sostanza si aprirà il classico dialog, nativo, per scegliere file/directory.

Per l'installazione:

flutter pub add file_picker

Qui sotto un esempio:

ElevatedButton(
  onPressed: () async {
    String? selectedDirectory =
        await FilePicker.platform.getDirectoryPath();

    if (selectedDirectory != null) {
      print(selectedDirectory);
    }
  },
  child: Text('Premi'),
),

Enjoy!


Condividi

Commentami!