file_tree_view 0.0.1 copy "file_tree_view: ^0.0.1" to clipboard
file_tree_view: ^0.0.1 copied to clipboard

A Flutter package for displaying foldable file directory trees.

File Tree View Flutter Package #

A Flutter package to view directories and files in a foldable tree structure. This package allows you to display files and folders in a tree view, with the ability to customize the folder and file icons, text styles, and handle file taps.

Features #

  • Folder and File Tree Structure: Display files and folders in a nested tree layout.
  • Foldable Directories: Allow users to expand and collapse directories.
  • Custom Icons: Easily customize folder and file icons.
  • Custom Text Styles: Style folder and file names using TextStyle.
  • File Tap Handler: Handle file taps to perform custom actions.
gif gif

Getting Started #

To get started, add the file_tree_view package to your pubspec.yaml file:

dependencies:
  file_tree_view: ^1.0.0

Basic Usage #

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('File Tree View')),
        body: DirectoryTreeViewer(rootPath: '/path/to/your/directory'), // Specify the root directory path
      ),
    );
  }
}

Custom Icons and TextStyle #

import 'package:file_tree_view/file_tree_view.dart';
import 'package:flutter/material.dart';
import 'package:file_icon/file_icon.dart';
import 'package:flutter_svg/flutter_svg.dart';

void main() {
  runApp(
    const MaterialApp(
      home:  Home()
    ));
}

class Home extends StatelessWidget {
  const Home({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xff181818),
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        iconTheme: const IconThemeData(color: Colors.grey),
      ),
      drawer: Drawer(
        backgroundColor:  const Color(0xff2b2b2b),
        child: SingleChildScrollView(
          child: SizedBox(
            child: DirectoryTreeViewer(
              rootPath: '/home/athul/Projects/AndroidApps/apps/survey_app', //Adjust the root path to desired folder
              folderNameStyle: const TextStyle(color: Colors.grey),
              fileNameStyle: const TextStyle(color: Colors.grey),
              folderClosedicon: SvgPicture.asset('assets/folder.svg',height: 28,width: 28),
              folderOpenedicon: SvgPicture.asset('assets/open-file-folder.svg',height: 28,width: 28),
              fileIconBuilder: (extension)=>FileIcon(extension),
          ),    
          ),
        ),
      ),
      body: const Center(child: Text("Example with custom icons",style: TextStyle(color: Colors.grey))),
    );
  }
}


5
likes
0
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for displaying foldable file directory trees.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, path

More

Packages that depend on file_tree_view