path_provider_watchos 0.0.1 copy "path_provider_watchos: ^0.0.1" to clipboard
path_provider_watchos: ^0.0.1 copied to clipboard

watchOS implementation of the path_provider plugin, using dart:ffi over Foundation to resolve the temporary, application-support, documents, and cache directories.

example/lib/main.dart

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

void main() => runApp(const ExampleApp());

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: PathList());
  }
}

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

  @override
  State<PathList> createState() => _PathListState();
}

class _PathListState extends State<PathList> {
  final Map<String, String> _paths = <String, String>{};

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

  Future<void> _load() async {
    Future<void> put(String label, Future<Object?> Function() f) async {
      try {
        final Object? dir = await f();
        _paths[label] = dir?.toString() ?? '(null)';
      } catch (e) {
        _paths[label] = 'unsupported';
      }
      if (mounted) {
        setState(() {});
      }
    }

    await put('temp', getTemporaryDirectory);
    await put('support', getApplicationSupportDirectory);
    await put('library', getLibraryDirectory);
    await put('documents', getApplicationDocumentsDirectory);
    await put('cache', getApplicationCacheDirectory);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: <Widget>[
          for (final MapEntry<String, String> e in _paths.entries)
            ListTile(
              dense: true,
              title: Text(e.key, style: const TextStyle(fontSize: 12)),
              subtitle: Text(e.value, style: const TextStyle(fontSize: 9)),
            ),
        ],
      ),
    );
  }
}
0
likes
140
points
6
downloads

Documentation

API reference

Publisher

verified publisherflutterwatch.dev

Weekly Downloads

watchOS implementation of the path_provider plugin, using dart:ffi over Foundation to resolve the temporary, application-support, documents, and cache directories.

Homepage
Repository (GitHub)
View/report issues

Topics

#watchos #ffi #path-provider #filesystem

License

BSD-3-Clause (license)

Dependencies

ffi, flutter, path_provider_platform_interface

More

Packages that depend on path_provider_watchos

Packages that implement path_provider_watchos