lecle_downloads_path_provider 0.0.2+8 copy "lecle_downloads_path_provider: ^0.0.2+8" to clipboard
lecle_downloads_path_provider: ^0.0.2+8 copied to clipboard

A Flutter project to get the downloads folder absolute path from Android and iOS device.

example/lib/main.dart

import 'dart:async';

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

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _downloadsPath = 'Unknown';

  @override
  void initState() {
    super.initState();
    initDownloadsDirectoryPath();
  }

  Future<void> initDownloadsDirectoryPath() async {
    String downloadsPath;
    try {
      downloadsPath = (await DownloadsPath.downloadsDirectory())?.path ??
          "Downloads path doesn't exist";

      // var dirType = DownloadDirectoryTypes.dcim;
      // downloadsPath = (await DownloadsPath.downloadsDirectory(dirType: dirType))?.path ?? "Downloads path doesn't exist";
    } catch (e) {
      downloadsPath = 'Failed to get downloads paths';
    }

    if (!mounted) return;

    setState(() {
      _downloadsPath = downloadsPath;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Downloads path example app'),
          centerTitle: true,
        ),
        body: Center(
          child: Text('Downloads path:\n $_downloadsPath\n',
              textAlign: TextAlign.center),
        ),
      ),
    );
  }
}
31
likes
160
points
4
downloads

Publisher

verified publisherlecle.vn

Weekly Downloads

A Flutter project to get the downloads folder absolute path from Android and iOS device.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on lecle_downloads_path_provider