open_file_safe_plus 0.0.7 copy "open_file_safe_plus: ^0.0.7" to clipboard
open_file_safe_plus: ^0.0.7 copied to clipboard

A plug-in that can call native APP to open files with string result in flutter, support iOS(UTI) / android(intent) / PC(ffi) / web(dart:html)

example/lib/main.dart

import 'dart:io';

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'open_file_safe_plus example',
      home: const MyHomePage(),
    );
  }
}

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

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _status = 'Idle';

  Future<void> _openFile() async {
    setState(() => _status = 'Writing file...');
    final file = File('${Directory.systemTemp.path}/open_file_test.txt');
    await file.writeAsString('open_file_safe_plus SPM test');

    final result = await OpenFileSafePlus.open(file.path);
    setState(() => _status = '${result.type}: ${result.message}');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('open_file_safe_plus example')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(_status),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: _openFile,
              child: const Text('Open test file'),
            ),
          ],
        ),
      ),
    );
  }
}
9
likes
160
points
1.06k
downloads

Documentation

API reference

Publisher

verified publishershadatrahman.com

Weekly Downloads

A plug-in that can call native APP to open files with string result in flutter, support iOS(UTI) / android(intent) / PC(ffi) / web(dart:html)

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

ffi, flutter

More

Packages that depend on open_file_safe_plus

Packages that implement open_file_safe_plus