external_path 1.0.3 copy "external_path: ^1.0.3" to clipboard
external_path: ^1.0.3 copied to clipboard

PlatformAndroid

A flutter plugin to get internal, external storage and external public directory path.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:external_path/external_path.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  List<String> _exPath = [];

  @override
  void initState() {
    super.initState();

    getPath();

    getPublicDirectoryPath();
  }

  // Get storage directory paths
  // Like internal and external (SD card) storage path
  Future<void> getPath() async {
    List<String> paths;
    // getExternalStorageDirectories() will return list containing internal storage directory path
    // And external storage (SD card) directory path (if exists)
    paths = await ExternalPath.getExternalStorageDirectories();

    setState(() {
      _exPath = paths; // [/storage/emulated/0, /storage/B3AE-4D28]
    });
  }

  // To get public storage directory path like Downloads, Picture, Movie etc.
  // Use below code
  Future<void> getPublicDirectoryPath() async {
    String path;

    path = await ExternalPath.getExternalStoragePublicDirectory(
        ExternalPath.DIRECTORY_DOWNLOADS);

    setState(() {
      print(path); // /storage/emulated/0/Download
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: ListView.builder(
          itemCount: _exPath.length,
          itemBuilder: (context, index) {
            return Center(child: Text("${_exPath[index]}"));
          }),
    ));
  }
}
111
likes
120
pub points
98%
popularity

Publisher

unverified uploader

A flutter plugin to get internal, external storage and external public directory path.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on external_path