file_picker 1.1.0 copy "file_picker: ^1.1.0" to clipboard
file_picker: ^1.1.0 copied to clipboard

outdated

A plugin that allows you to pick absolute paths from diferent file types.

pub package Awesome Flutter

file_picker #

File picker plugin alows you to use a native file explorer to load absolute file path from different file types.

Installation #

First, add file_picker as a dependency in your pubspec.yaml file.

file_picker: ^1.1.0

Android #

Add <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> to your app AndroidManifest.xml file.

iOS #

Since we are using image_picker as a dependency from this plugin to load paths from gallery and camera, we need the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
  • NSCameraUsageDescription - describe why your app needs access to the camera. This is called Privacy - Camera Usage Description in the visual editor.
  • NSMicrophoneUsageDescription - describe why your app needs access to the microphone, if you intend to record videos. This is called Privacy - Microphone Usage Description in the visual editor.
  • UIBackgroundModes with the fetch and remote-notifications keys - describe why your app needs to access background taks, such downloading files (from cloud services) when not cached to locate path. This is called Required background modes, with the keys App download content from network and App downloads content in response to push notifications respectively in the visual editor (since both methods aren't actually overriden, not adding this property/keys may only display a warning, but shouldn't prevent its correct usage).

Currently supported features #

  • ✅ Load paths from cloud files (GDrive, Dropbox, iCloud)
  • ✅ Load path from gallery
  • ✅ Load path from camera
  • ✅ Load path from video
  • ✅ Load path from any type of file (without filtering)
  • ✅ Load path from a custom format by providing a file extension (pdf, svg, zip, etc.)

Demo App #

Demo

Example #

import 'package:file_picker/file_picker.dart';

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _filePath;

  void getFilePath() async {
   try {
      String filePath = await FilePicker.getFilePath(type: FileType.ANY);
      if (filePath == '') {
        return;
      }
      print("File path: " + filePath);
      setState((){this._filePath = filePath;});
    } on PlatformException catch (e) {
      print("Error while picking the file: " + e.toString());
    }
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('File Picker Example'),
      ),
      body: new Center(
        child: _filePath == null
            ? new Text('No file selected.')
            : new Text('Path' + _filePath),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: getFilePath,
        tooltip: 'Select file',
        child: new Icon(Icons.sd_storage),
      ),
    );
  }
}

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

4456
likes
0
pub points
100%
popularity

Publisher

verified publishermiguelruivo.com

A plugin that allows you to pick absolute paths from diferent file types.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, image_picker, meta

More

Packages that depend on file_picker