fixes a few iOS bugs
This commit is contained in:
parent
2adaebc097
commit
d23d94882d
|
@ -56,10 +56,6 @@ public class FilePickerPlugin implements MethodCallHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnActivityResult()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void startFileExplorer()
|
private void startFileExplorer()
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
@ -18,8 +17,8 @@ class _MyAppState extends State<MyApp> {
|
||||||
void _openFileExplorer() async {
|
void _openFileExplorer() async {
|
||||||
try {
|
try {
|
||||||
_path = await FilePicker.getFilePath;
|
_path = await FilePicker.getFilePath;
|
||||||
} on PlatformException {
|
} on PlatformException catch (e) {
|
||||||
print('Something went wrong...');
|
print(e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
@ -46,7 +45,7 @@ class _MyAppState extends State<MyApp> {
|
||||||
child: new Column(
|
child: new Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
new Padding(
|
||||||
padding: const EdgeInsets.all(20.0),
|
padding: const EdgeInsets.all(20.0),
|
||||||
child: new RaisedButton(
|
child: new RaisedButton(
|
||||||
onPressed: () => _openFileExplorer(),
|
onPressed: () => _openFileExplorer(),
|
||||||
|
@ -55,18 +54,27 @@ class _MyAppState extends State<MyApp> {
|
||||||
),
|
),
|
||||||
new Text(
|
new Text(
|
||||||
'URI PATH ',
|
'URI PATH ',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
style: new TextStyle(fontWeight: FontWeight.bold),
|
style: new TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
new Text(
|
new Text(
|
||||||
_path,
|
_path,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
softWrap: true,
|
softWrap: true,
|
||||||
textScaleFactor: 0.85,
|
textScaleFactor: 0.85,
|
||||||
),
|
),
|
||||||
Padding(
|
new Padding(
|
||||||
padding: const EdgeInsets.only(top: 10.0),
|
padding: const EdgeInsets.only(top: 10.0),
|
||||||
child: new Text('FILE NAME ', style: new TextStyle(fontWeight: FontWeight.bold)),
|
child: new Text(
|
||||||
|
'FILE NAME ',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: new TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
new Text(
|
||||||
|
_fileName,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
new Text(_fileName),
|
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
UIDocumentInteractionController *_interactionController;
|
UIDocumentInteractionController *_interactionController;
|
||||||
|
|
||||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||||
|
|
||||||
FlutterMethodChannel* channel = [FlutterMethodChannel
|
FlutterMethodChannel* channel = [FlutterMethodChannel
|
||||||
methodChannelWithName:@"file_picker"
|
methodChannelWithName:@"file_picker"
|
||||||
binaryMessenger:[registrar messenger]];
|
binaryMessenger:[registrar messenger]];
|
||||||
|
|
||||||
|
UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||||
UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
|
||||||
FilePickerPlugin* instance = [[FilePickerPlugin alloc] initWithViewController:viewController];
|
FilePickerPlugin* instance = [[FilePickerPlugin alloc] initWithViewController:viewController];
|
||||||
|
|
||||||
[registrar addMethodCallDelegate:instance channel:channel];
|
[registrar addMethodCallDelegate:instance channel:channel];
|
||||||
|
@ -61,13 +61,13 @@ didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls{
|
||||||
|
|
||||||
[_pickerController dismissViewControllerAnimated:YES completion:nil];
|
[_pickerController dismissViewControllerAnimated:YES completion:nil];
|
||||||
|
|
||||||
NSMutableArray *resultUrls = [[NSMutableArray alloc] init];
|
NSString * uri;
|
||||||
|
|
||||||
for (NSURL *url in urls) {
|
for (NSURL *url in urls) {
|
||||||
[resultUrls addObject: (NSString *)[url path]];
|
uri = (NSString *)[url path];
|
||||||
}
|
}
|
||||||
|
|
||||||
_result(resultUrls);
|
_result(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DocumentInteractionController delegate
|
// DocumentInteractionController delegate
|
||||||
|
|
Loading…
Reference in New Issue