android_path_provider 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

android_path_provider #

pub package

Flutter plugin for getting Android directories. (Downloads, Movies, Pictures...). This plugin only works on Android platform.

Usage #

void getAndroidPaths() async {
    var alarmsPath = await AndroidPathProvider.alarmsPath;
    var dcimPath = await AndroidPathProvider.dcimPath;
    var documentsPath = await AndroidPathProvider.documentsPath;
    var downloadsPath = await AndroidPathProvider.downloadsPath;
    var moviesPath = await AndroidPathProvider.moviesPath;
    var musicPath = await AndroidPathProvider.musicPath;
    var notificationsPath = await AndroidPathProvider.notificationsPath;
    var picturesPath = await AndroidPathProvider.picturesPath;
    var podcastsPath = await AndroidPathProvider.podcastsPath;
    var ringtonesPath = await AndroidPathProvider.ringtonesPath;
}

[0.1.0] - 2019/10/02 #

  • initial release

[0.1.1] - 2020/02/18 #

  • update dependency

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:android_path_provider/android_path_provider.dart';

void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> {
  String _alarmsPath = 'Unknown';
  // String _audiobooksPath = 'Unknown';
  String _dcimPath = 'Unknown';
  String _documentsPath = 'Unknown';
  String _downloadsPath = 'Unknown';
  String _moviesPath = 'Unknown';
  String _musicPath = 'Unknown';
  String _notificationsPath = 'Unknown';
  String _picturesPath = 'Unknown';
  String _podcastsPath = 'Unknown';
  String _ringtonesPath = 'Unknown';
  // String _screenshotsPath = 'Unknown';

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

  Future<void> initAndroidPaths() async {
    String alarmsPath;
    // String audiobooksPath;
    String dcimPath;
    String documentsPath;
    String downloadsPath;
    String moviesPath;
    String musicPath;
    String notificationsPath;
    String picturesPath;
    String podcastsPath;
    String ringtonesPath;
    // String screenshotsPath;

    try {
      alarmsPath = await AndroidPathProvider.alarmsPath;
      // audiobooksPath = await AndroidPathProvider.audiobooksPath;
      dcimPath = await AndroidPathProvider.dcimPath;
      documentsPath = await AndroidPathProvider.documentsPath;
      downloadsPath = await AndroidPathProvider.downloadsPath;
      moviesPath = await AndroidPathProvider.moviesPath;
      musicPath = await AndroidPathProvider.musicPath;
      notificationsPath = await AndroidPathProvider.notificationsPath;
      picturesPath = await AndroidPathProvider.picturesPath;
      podcastsPath = await AndroidPathProvider.podcastsPath;
      ringtonesPath = await AndroidPathProvider.ringtonesPath;
      // screenshotsPath = await AndroidPathProvider.screenshotsPath;
    } on PlatformException {}

    if (!mounted) return;

    setState(() {
      _alarmsPath = alarmsPath;
      // _audiobooksPath = audiobooksPath;
      _dcimPath = dcimPath;
      _documentsPath = documentsPath;
      _downloadsPath = downloadsPath;
      _moviesPath = moviesPath;
      _musicPath = musicPath;
      _notificationsPath = notificationsPath;
      _picturesPath = picturesPath;
      _podcastsPath = podcastsPath;
      _ringtonesPath = ringtonesPath;
      // _screenshotsPath = screenshotsPath;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('android_path_provider'),
        ),
        body: Column(
          children: <Widget>[
            Center(
              child: Text('alarmsPath: $_alarmsPath'),
            ),
            // Center(
            //   child: Text('audiobooksPath: $_audiobooksPath'),
            // ),
            Center(
              child: Text('dcimPath: $_dcimPath'),
            ),
            Center(
              child: Text('documentsPath: $_documentsPath'),
            ),
            Center(
              child: Text('downloadsPath: $_downloadsPath'),
            ),
            Center(
              child: Text('moviesPath: $_moviesPath'),
            ),
            Center(
              child: Text('musicPath: $_musicPath'),
            ),
            Center(
              child: Text('notificationsPath: $_notificationsPath'),
            ),
            Center(
              child: Text('picturesPath: $_picturesPath'),
            ),
            Center(
              child: Text('podcastsPath: $_podcastsPath'),
            ),
            Center(
              child: Text('ringtonesPath: $_ringtonesPath'),
            ),
            // Center(
            //   child: Text('screenshotsPath: $_screenshotsPath'),
            // ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  android_path_provider: ^0.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:android_path_provider/android_path_provider.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
49
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test