downloadsfolder 0.0.5 copy "downloadsfolder: ^0.0.5" to clipboard
downloadsfolder: ^0.0.5 copied to clipboard

A Flutter plugin for retrieving the path to the downloads folder and performing operations related to file downloads on different platforms.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:downloadsfolder/downloadsfolder.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

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

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


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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String downloadsfolderPath;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      downloadsfolderPath =
          await getDownloadDirectoryPath() ?? 'Unknown';
    } on PlatformException {
      downloadsfolderPath = 'Failed to get folder path.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _downloadsfolderPath = downloadsfolderPath;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Downloads Folder Path: $_downloadsfolderPath\n'),
        ),
      ),
    );
  }
}
36
likes
0
points
8.02k
downloads

Publisher

verified publishersiyoutechnology.com

Weekly Downloads

A Flutter plugin for retrieving the path to the downloads folder and performing operations related to file downloads on different platforms.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dartx, device_info_plus, diacritic, flutter, path, path_provider, path_provider_windows, permission_handler, plugin_platform_interface, url_launcher

More

Packages that depend on downloadsfolder