open_file_plus 3.4.1+1 open_file_plus: ^3.4.1+1 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)
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:open_file_plus/open_file_plus.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
var _openResult = 'Unknown';
Future<void> openFile() async {
final filePath = '/storage/emulated/0/update.apk';
final result = await OpenFile.open(filePath);
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: openFile,
),
],
),
),
),
);
}
}