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

outdated

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";
      print('Download path ::: $downloadsPath');
    } 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),
        ),
      ),
    );
  }
}
32
likes
0
pub points
96%
popularity

Publisher

verified publisherlecle.vn

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

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on lecle_downloads_path_provider