Coder Social home page Coder Social logo

filex's Introduction

Filex

pub package

Configurable file explorer widget for Flutter

Screenshot

Usage

Simple:

import 'package:filex/filex.dart';
import 'package:path_provider/path_provider.dart';

dir = await getApplicationDocumentsDirectory();
final controller = FilexController(path: dir.path);
Filex(controller: controller);

With leading and trailing builders:

import 'package:filex/filex.dart';

Filex(
  compact: true,
  directory: Directory("some_dir_path"),
  directoryTrailingBuilder: (context, item) {
    return GestureDetector(
      child: Padding(
        padding: const EdgeInsets.fromLTRB(0, 0, 3.0, 0),
        child: Icon(Icons.file_download,
          color: Colors.grey, size: 20.0)),
        onTap: () => doSomething(item));
})

Trailing and leading options are: fileTrailingBuilder, directoryLeadingBuilder and directoryTrailingBuilder

Controller

Include dialogs to add and delete directories:

class FileExplorer extends StatelessWidget {
@override
Widget build(BuildContext context) {
   final controller = FilexController(path: dir.path);
   return Scaffold(
      appBar: AppBar(
        title: const Text("Files"),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.add),
            onPressed: () => controller.addDirectory(context),
          )
        ],
      ),
      body: Filex(
        controller: controller,
        actions: <PredefinedAction>[PredefinedAction.delete],
      ),
    );
  }
}

Available controller actions:

controller.delete(DirectoryItem item) : delete a file or directory

controller.createDirectory(String name) : create a directory

controller.ls() : list the current directory

controller.dispose() : dispose the bloc when finished using

Custom actions

It is possible to add custom actions in the slidable menu:

Filex(
    controller: controller,
    actions: <PredefinedAction>[PredefinedAction.delete],
    extraActions: <FilexSlidableAction>[
    FilexSlidableAction(
        name: "My action",
        iconData: Icons.file_upload,
        color: Colors.blue,
        onTap: customAction,
    )
    ],
)

void customAction(BuildContext context, DirectoryItem item) {
    // action here
}

Changefeed

A stream with directory listing items is available to implement on change callbacks:

StreamSubscription<List<DirectoryItem>> _sub;
_sub = controller.changefeed.listen((items) {
  // do something
});

filex's People

Contributors

mdmohsin7 avatar synw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

filex's Issues

Feature Request : Add support for top navigation irrespective of the current folder path

Currently, top navigation is visible for non root directories. But in our current applications, once a user selects a folder, the root directory is changed to this directory (to help him navigating). Now, the user is unable to go back to the parent folder, in case if he wants to change it.

If we don't change the root folder, then every time, user has to navigate himself.

Can I work on this and raise a pr to make this top navigation optional?

File list overflowing

When in a non-root folder, where the topNavigation is shown, the listview of files is overflowing on the bottom.

Need Upgrade for flutter 2.0.2 null safety

need null safety version for this plugin. I upgrade my project to flutter 2.0.2. After that when goes to upgrade plugins, ex. for path_provider through

filex 0.3.0 depends on path_provider ^1.6.24 and no versions of filex match >0.3.0 <0.4.0, filex ^0.3.0 requires path_provider ^1.6.24.
So, because myapps depends on both path_provider 2.0.1 and filex ^0.3.0, version solving failed.
pub get failed (1; So, because myapps depends on both path_provider 2.0.1 and filex ^0.3.0, version solving failed.)
exit code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.