open_file_mac 1.0.4 copy "open_file_mac: ^1.0.4" to clipboard
open_file_mac: ^1.0.4 copied to clipboard

PlatformmacOS

MacOS implementation of the open_file plugin.

example/lib/main.dart

import 'dart:async';

import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:open_file_mac/open_file_mac.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var _openResult = 'Unknown';

  Future<void> _openPickFile() async {
    FilePickerResult? fileResult = await FilePicker.platform.pickFiles();
    if (fileResult?.files.first != null) {
      final result = await OpenFileMac().open(fileResult!.files.first.path);
      setState(() {
        _openResult = "type=${result.type}  message=${result.message}";
      });
    }
  }

  Future<void> openFile() async {
    final result =
        await OpenFileMac().open("/Users/chendong/Downloads/R-C.jpeg");
    setState(() {
      _openResult = "type=${result.type}  message=${result.message}";
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text('open result: $_openResult\n'),
              TextButton(
                child: Text('Tap to open file'),
                onPressed: _openPickFile,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
210k
downloads

Publisher

unverified uploader

Weekly Downloads

MacOS implementation of the open_file plugin.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, open_file_platform_interface

More

Packages that depend on open_file_mac

Packages that implement open_file_mac