ios_document_picker 0.3.0 copy "ios_document_picker: ^0.3.0" to clipboard
ios_document_picker: ^0.3.0 copied to clipboard

PlatformiOS

Flutter wrapper of iOS UIDocumentPickerViewController.

example/lib/main.dart

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

import 'package:ios_document_picker/ios_document_picker.dart';
import 'package:ios_document_picker/ios_document_picker_platform_interface.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 _iosDocumentPickerPlugin = IosDocumentPicker();
  var _output = '';
  var _mode = IosDocumentPickerType.file;
  var _multiple = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: SingleChildScrollView(
          child: Container(
            padding: const EdgeInsets.all(20),
            child: Column(
              children: [
                Text(_output),
                const SizedBox(
                  height: 10,
                ),
                ListTile(
                  title: const Text('File'),
                  leading: Radio<IosDocumentPickerType>(
                    value: IosDocumentPickerType.file,
                    groupValue: _mode,
                    onChanged: (IosDocumentPickerType? value) {
                      setState(() {
                        _mode = value!;
                      });
                    },
                  ),
                ),
                ListTile(
                  title: const Text('Directory'),
                  leading: Radio<IosDocumentPickerType>(
                    value: IosDocumentPickerType.directory,
                    groupValue: _mode,
                    onChanged: (IosDocumentPickerType? value) {
                      setState(() {
                        _mode = value!;
                      });
                    },
                  ),
                ),
                const SizedBox(
                  height: 10,
                ),
                CheckboxListTile(
                    value: _multiple,
                    onChanged: (value) {
                      setState(() {
                        _multiple = value!;
                      });
                    },
                    title: const Text('Multiple selection')),
                const SizedBox(
                  height: 10,
                ),
                OutlinedButton(onPressed: _start, child: const Text('Pick'))
              ],
            ),
          ),
        ),
      ),
    );
  }

  Future<void> _start() async {
    var result =
        await _iosDocumentPickerPlugin.pick(_mode, multiple: _multiple);
    if (result == null) {
      setState(() {
        _output = 'Cancelled';
      });
      return;
    }
    setState(() {
      _output = result.map((e) => e.toString()).join('\n\n');
    });
  }
}
1
likes
150
points
229
downloads

Publisher

verified publisherflutter-cavalry.com

Weekly Downloads

Flutter wrapper of iOS UIDocumentPickerViewController.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on ios_document_picker