fixes a few iOS bugs

This commit is contained in:
Miguel Ruivo 2018-06-24 16:07:34 +01:00
parent 2adaebc097
commit d23d94882d
3 changed files with 21 additions and 17 deletions

View File

@ -56,10 +56,6 @@ public class FilePickerPlugin implements MethodCallHandler {
}
}
private void setOnActivityResult()
{
}
private void startFileExplorer()

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:file_picker/file_picker.dart';
@ -18,8 +17,8 @@ class _MyAppState extends State<MyApp> {
void _openFileExplorer() async {
try {
_path = await FilePicker.getFilePath;
} on PlatformException {
print('Something went wrong...');
} on PlatformException catch (e) {
print(e.toString());
}
if (!mounted) return;
@ -46,7 +45,7 @@ class _MyAppState extends State<MyApp> {
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
new Padding(
padding: const EdgeInsets.all(20.0),
child: new RaisedButton(
onPressed: () => _openFileExplorer(),
@ -55,18 +54,27 @@ class _MyAppState extends State<MyApp> {
),
new Text(
'URI PATH ',
textAlign: TextAlign.center,
style: new TextStyle(fontWeight: FontWeight.bold),
),
new Text(
_path,
textAlign: TextAlign.center,
softWrap: true,
textScaleFactor: 0.85,
),
Padding(
new Padding(
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),
],
)),
),

View File

@ -7,12 +7,12 @@
UIDocumentInteractionController *_interactionController;
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel* channel = [FlutterMethodChannel
methodChannelWithName:@"file_picker"
binaryMessenger:[registrar messenger]];
UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController;
UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController;
FilePickerPlugin* instance = [[FilePickerPlugin alloc] initWithViewController:viewController];
[registrar addMethodCallDelegate:instance channel:channel];
@ -61,13 +61,13 @@ didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls{
[_pickerController dismissViewControllerAnimated:YES completion:nil];
NSMutableArray *resultUrls = [[NSMutableArray alloc] init];
NSString * uri;
for (NSURL *url in urls) {
[resultUrls addObject: (NSString *)[url path]];
uri = (NSString *)[url path];
}
_result(resultUrls);
_result(uri);
}
// DocumentInteractionController delegate