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

PlatformmacOS

A flutter plugin for macOS to open files or view files in Finder.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:open_file_macos/open_file_macos.dart';
import 'package:tmp_path/tmp_path.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  final _openFileMacosPlugin = OpenFileMacos();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            ElevatedButton(
              onPressed: () async {
                try {
                  final tmpFile = '${tmpPath()}.txt';
                  await File(tmpFile).writeAsString('Hello world!');
                  await _openFileMacosPlugin.open(tmpFile);
                } catch (err) {
                  print(err);
                }
              },
              child: const Text('Open file'),
            ),
            ElevatedButton(
              onPressed: () async {
                try {
                  final tmpFile = '${tmpPath()}.txt';
                  await File(tmpFile).writeAsString('Hello world!');
                  await _openFileMacosPlugin.open(tmpFile, viewInFinder: true);
                } catch (err) {
                  print(err);
                }
              },
              child: const Text('Open file in Finder'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
pub points
69%
popularity

Publisher

verified publisherflutter-cavalry.com

A flutter plugin for macOS to open files or view files in Finder.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on open_file_macos