Remove url_lancher and path_provider from services (#9916)
This commit is contained in:
@@ -22,7 +22,6 @@ export 'src/services/image_resolution.dart';
|
||||
export 'src/services/image_stream.dart';
|
||||
export 'src/services/message_codec.dart';
|
||||
export 'src/services/message_codecs.dart';
|
||||
export 'src/services/path_provider.dart';
|
||||
export 'src/services/platform_channel.dart';
|
||||
export 'src/services/platform_messages.dart';
|
||||
export 'src/services/raw_keyboard.dart';
|
||||
@@ -33,4 +32,3 @@ export 'src/services/system_sound.dart';
|
||||
export 'src/services/text_editing.dart';
|
||||
export 'src/services/text_formatter.dart';
|
||||
export 'src/services/text_input.dart';
|
||||
export 'src/services/url_launcher.dart';
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'system_channels.dart';
|
||||
|
||||
/// Returns commonly used locations on the filesystem.
|
||||
class PathProvider {
|
||||
PathProvider._();
|
||||
|
||||
/// Path to the temporary directory on the device.
|
||||
///
|
||||
/// Files in this directory may be cleared at any time. This does *not* return
|
||||
/// a new temporary directory. Instead, the caller is responsible for creating
|
||||
/// (and cleaning up) files or directories within this directory. This
|
||||
/// directory is scoped to the calling application.
|
||||
///
|
||||
/// On iOS, this uses the `NSTemporaryDirectory` API.
|
||||
///
|
||||
/// On Android, this uses the `getCacheDir` API on the context.
|
||||
static Future<Directory> getTemporaryDirectory() async {
|
||||
final String path = await SystemChannels.platform.invokeMethod('PathProvider.getTemporaryDirectory');
|
||||
if (path == null)
|
||||
return null;
|
||||
return new Directory(path);
|
||||
}
|
||||
|
||||
/// Path to a directory where the application may place files that are private
|
||||
/// to the application and will only be cleared when the application itself
|
||||
/// is deleted.
|
||||
///
|
||||
/// On iOS, this uses the `NSDocumentsDirectory` API.
|
||||
///
|
||||
/// On Android, this returns the AppData directory.
|
||||
static Future<Directory> getApplicationDocumentsDirectory() async {
|
||||
final String path = await SystemChannels.platform.invokeMethod('PathProvider.getApplicationDocumentsDirectory');
|
||||
if (path == null)
|
||||
return null;
|
||||
return new Directory(path);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'system_channels.dart';
|
||||
|
||||
/// Allows applications to delegate responsbility of handling certain URLs to
|
||||
/// the underlying platform.
|
||||
class UrlLauncher {
|
||||
UrlLauncher._();
|
||||
|
||||
/// Parse the specified URL string and delegate handling of the same to the
|
||||
/// underlying platform.
|
||||
static Future<Null> launch(String urlString) async {
|
||||
await SystemChannels.platform.invokeMethod(
|
||||
'UrlLauncher.launch',
|
||||
urlString,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -886,7 +886,8 @@ abstract class State<T extends StatefulWidget> {
|
||||
/// setState(() {
|
||||
/// _counter++;
|
||||
/// });
|
||||
/// final String dir = await PathProvider.getApplicationDocumentsDirectory();
|
||||
/// Directory directory = await getApplicationDocumentsDirectory();
|
||||
/// final String dirName = directory.path;
|
||||
/// await new File('$dir/counter.txt').writeAsString('$_counter');
|
||||
/// return null;
|
||||
/// }
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('Path provider control test', () async {
|
||||
final List<MethodCall> log = <MethodCall>[];
|
||||
String response;
|
||||
|
||||
SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
log.add(methodCall);
|
||||
return response;
|
||||
});
|
||||
|
||||
Directory directory = await PathProvider.getTemporaryDirectory();
|
||||
|
||||
expect(log, equals(<MethodCall>[new MethodCall('PathProvider.getTemporaryDirectory')]));
|
||||
expect(directory, isNull);
|
||||
log.clear();
|
||||
|
||||
directory = await PathProvider.getApplicationDocumentsDirectory();
|
||||
|
||||
expect(log, equals(<MethodCall>[new MethodCall('PathProvider.getApplicationDocumentsDirectory')]));
|
||||
expect(directory, isNull);
|
||||
|
||||
final String fakePath = "/foo/bar/baz";
|
||||
response = fakePath;
|
||||
|
||||
directory = await PathProvider.getTemporaryDirectory();
|
||||
expect(directory.path, equals(fakePath));
|
||||
|
||||
directory = await PathProvider.getApplicationDocumentsDirectory();
|
||||
expect(directory.path, equals(fakePath));
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('URL launcher control test', () async {
|
||||
final List<MethodCall> log = <MethodCall>[];
|
||||
|
||||
SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
log.add(methodCall);
|
||||
});
|
||||
|
||||
await UrlLauncher.launch('http://example.com/');
|
||||
|
||||
expect(log, equals(<MethodCall>[new MethodCall('UrlLauncher.launch', 'http://example.com/')]));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user