Skip to content

kw2019ltd/flutter_file_utils

 
 

Repository files navigation

flutter_file_utils

Helper tools for managing files on Android.

Getting Started

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

For help on editing package code, view the documentation.

Screenshots

Usage

To use this package, add these
dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  path_provider: ^1.6.7
  flutter_file_utils: ^0.1.1

And, add read / write permissions in your android/app/src/main/AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Don't forget to grant Storage permissions to your app, manually or by this plugin simple_permissions

// dart files
import 'dart:async';

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

// packages
import 'package:path_provider/path_provider.dart';
import 'package:flutter_file_utils/flutter_file_utils.dart';
import 'package:simple_permissions/simple_permissions.dart';

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

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    SimplePermissions.requestPermission(Permission.ReadExternalStorage);
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Flutter File Manager Example"),
        ),
        body: FutureBuilder(
            future: _files(),
            builder: (BuildContext context, AsyncSnapshot snapshot) {
              if (snapshot.connectionState == ConnectionState.done) {
                return ListView.builder(
                  itemCount: snapshot.data?.length ?? 0,
                  itemBuilder: (context, index) {
                    return ListTile(
                      title: Text(snapshot.data[index].path.split('/').last),
                    );
                  },
                );
              } else if (snapshot.connectionState == ConnectionState.waiting) {
                return Center(child: Text("Loading"));
              }
            }),
      ),
    );
  }

  _files() async {
    var root = await getExternalStorageDirectory();
    var files = await FileManager(root: root).walk().toList();
    return files;
  }
}

Examples

Features

  • File Details
  • Search files or directories: supports regular expressions
  • Recent created files: you can exclude a list of directories from the tree
  • Directories only tree: you can exclude a list of directories from the tree
  • Files only tree: you can exclude a list of directories from the tree
  • Files list from specific point
  • Delete files
  • Delete directory
  • Temp file
  • Sorting
    • Type
    • Size
    • Date
    • Alpha
  • Filtering
    • Extensions
    • Files only
    • Directories only
  • System Tools
    • Copy
    • Rename

Contributors

Donate

Contact me

About

Flutter package for managing files on Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 97.1%
  • Java 2.9%