open_file 3.0.1

Flutter Android iOS

A plug-in that can call native APP to open files with string result in flutter,support iOS(UTI) and android(intent)

example/lib/main.dart

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

import 'package:open_file/open_file.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _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 new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text('open result: $_openResult\n'),
              FlatButton(
                child: Text('Tap to open file'),
                onPressed: openFile,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
95
likes
80
pub points
97%
popularity

A plug-in that can call native APP to open files with string result in flutter,support iOS(UTI) and android(intent)

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

21527312@qq.com

License

BSD (LICENSE)

Dependencies

ffi, flutter

More

Packages that depend on open_file