filesaverz 3.2.1 copy "filesaverz: ^3.2.1" to clipboard
filesaverz: ^3.2.1 copied to clipboard

PlatformAndroid

A customable file saver and file picker package that makes it easy for user to browse folder and save file or pick files in android.

example/lib/main.dart

import 'dart:io';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:filesaverz/filesaverz.dart';

void main() {
  runApp(const MaterialApp(
    title: 'File Saver Example',
    debugShowCheckedModeBanner: false,
    home: MyApp(),
  ));
}

/// Homepage.
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    /// Setting up file explorer.
    FileSaver fileSaver = FileSaver(
      initialFileName: 'New File',
      fileTypes: const ['txt'],
    );

    return Scaffold(
      body: Center(
        child: Column(mainAxisSize: MainAxisSize.min, children: [
          /// Save File.
          MyButton(
            text: 'Save File',
            icon: Icons.save,
            onTap: () {
              fileSaver.writeAsString('Hello World', context: context);
            },
          ),

          /// Pick File.
          MyButton(
            text: 'Pick File',
            icon: Icons.insert_drive_file_rounded,
            onTap: () async {
              File? file = await fileSaver.pickFile(context);
              log(file.toString());
            },
          ),

          /// Pick Multiple Files.
          MyButton(
            text: 'Pick Files',
            icon: Icons.file_copy,
            onTap: () async {
              List<File>? files = await fileSaver.pickFiles(context);
              log(files.toString());
            },
          ),
        ]),
      ),
    );
  }
}

/// Custom button.
class MyButton extends StatelessWidget {
  const MyButton({Key? key, required this.text, required this.icon, this.onTap})
      : super(key: key);

  final String text;
  final IconData icon;
  final void Function()? onTap;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 10.0),
      child: Material(
        color: Colors.blue,
        child: InkWell(
          onTap: onTap,
          child: Padding(
            padding: const EdgeInsets.all(10),
            child: Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                Icon(icon, color: Colors.white),
                const SizedBox(
                  width: 10,
                ),
                Text(
                  text,
                  style: const TextStyle(
                    color: Colors.white,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
15
likes
140
pub points
61%
popularity
screenshot

Publisher

verified publisherinidia.app

A customable file saver and file picker package that makes it easy for user to browse folder and save file or pick files in android.

Homepage
Repository (GitHub)
View/report issues

Topics

#utility #file #saver #picker #android

Documentation

API reference

Funding

Consider supporting this project:

ko-fi.com

License

MIT (LICENSE)

Dependencies

flutter, permission_handler, provider

More

Packages that depend on filesaverz