Simple File Manager Built Using Flutter

file manager, flutter file manager app, flutter file manager, file manager app built in flutter, flutter file manager github, flutter flie manager app code

Simple File Manager

A Simple file manager which can preview folders and file in simple way and download files from it.



Follow below example

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  State<MyHomePage> createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  void initState() {


  init() async {
    _myData = await getFilesData(null);
    setState(() {});

  List<FileModel>? _myData;

  /// Get url data using api or anyway you want
  Future<List<FileModel>?> getFilesData(String? parentId) async {
    var response = await http.get(
        Uri.parse('yourBaseUrl.api/file/tree?parentId=${parentId ?? ''}&skip=0'
    Map<String, dynamic> json = jsonDecode(response.body);
    return List<FileModel>.from(json['data'].map((e) => FileModel.fromJson(e)));

  Future<String> uploadFile(
      String? folderId, Uint8List? pickedFile, String? pickedFileName) async {
    var request = http.MultipartRequest(
      filename: pickedFileName,
      contentType: MediaType("image", pickedFileName!.split('.').last),
    request.fields['name'] = pickedFileName;
    request.headers["Content-Type"] = "image/jpg";
    request.fields['path'] = 'img';
    request.fields['type'] = 'File';
    request.fields['parentId'] = folderId!;

    var response = await request.send();
    var data = await;
    String dataString = utf8.decode(data);
    var r = json.decode(dataString);
    return r['data']['thumbnailUrl'];

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: Center(
        child: Column(
          children: <Widget>[
            if (_myData != null)
                filesList: _myData!,
                uploadButtonText: 'Upload',
                onUpload: (String? parentId, pickedFile,
                    String? pickedFileName) async {
                  if (pickedFile != null) {
                    return await uploadFile(
                        parentId, pickedFile, pickedFileName);
                  } else {
                    return null;
                onCreateFolderClicked: (String? parentID) {},
                onBack: (String? value) async {
                  return await getFilesData(value);
                onFolderClicked: (value) async {
                  return await getFilesData(value!.id);
                placeholderFromAssets: 'assets/images/placeholder.png',

5/5 (2 votes)
Share to:
Scroll to Top