From d6b1ad5456569dca376789ab98fbe0ee737087b3 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Tue, 9 May 2017 15:13:05 +0200 Subject: [PATCH] Remove url_lancher and path_provider from services (#9916) --- packages/flutter/lib/services.dart | 2 - .../lib/src/services/path_provider.dart | 44 ------------------- .../lib/src/services/url_launcher.dart | 22 ---------- .../flutter/lib/src/widgets/framework.dart | 3 +- .../test/services/path_provider_test.dart | 40 ----------------- .../test/services/url_launcher_test.dart | 20 --------- 6 files changed, 2 insertions(+), 129 deletions(-) delete mode 100644 packages/flutter/lib/src/services/path_provider.dart delete mode 100644 packages/flutter/lib/src/services/url_launcher.dart delete mode 100644 packages/flutter/test/services/path_provider_test.dart delete mode 100644 packages/flutter/test/services/url_launcher_test.dart diff --git a/packages/flutter/lib/services.dart b/packages/flutter/lib/services.dart index 90fc1a8460..74e1858e69 100644 --- a/packages/flutter/lib/services.dart +++ b/packages/flutter/lib/services.dart @@ -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'; diff --git a/packages/flutter/lib/src/services/path_provider.dart b/packages/flutter/lib/src/services/path_provider.dart deleted file mode 100644 index 891bbfeebf..0000000000 --- a/packages/flutter/lib/src/services/path_provider.dart +++ /dev/null @@ -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 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 getApplicationDocumentsDirectory() async { - final String path = await SystemChannels.platform.invokeMethod('PathProvider.getApplicationDocumentsDirectory'); - if (path == null) - return null; - return new Directory(path); - } -} diff --git a/packages/flutter/lib/src/services/url_launcher.dart b/packages/flutter/lib/src/services/url_launcher.dart deleted file mode 100644 index 75ed4ed387..0000000000 --- a/packages/flutter/lib/src/services/url_launcher.dart +++ /dev/null @@ -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 launch(String urlString) async { - await SystemChannels.platform.invokeMethod( - 'UrlLauncher.launch', - urlString, - ); - } -} diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index e9a52eb0a9..92035abb7a 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -886,7 +886,8 @@ abstract class State { /// 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; /// } diff --git a/packages/flutter/test/services/path_provider_test.dart b/packages/flutter/test/services/path_provider_test.dart deleted file mode 100644 index a31823daac..0000000000 --- a/packages/flutter/test/services/path_provider_test.dart +++ /dev/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 log = []; - String response; - - SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async { - log.add(methodCall); - return response; - }); - - Directory directory = await PathProvider.getTemporaryDirectory(); - - expect(log, equals([new MethodCall('PathProvider.getTemporaryDirectory')])); - expect(directory, isNull); - log.clear(); - - directory = await PathProvider.getApplicationDocumentsDirectory(); - - expect(log, equals([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)); - }); -} diff --git a/packages/flutter/test/services/url_launcher_test.dart b/packages/flutter/test/services/url_launcher_test.dart deleted file mode 100644 index 31e4fa2eee..0000000000 --- a/packages/flutter/test/services/url_launcher_test.dart +++ /dev/null @@ -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 log = []; - - SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async { - log.add(methodCall); - }); - - await UrlLauncher.launch('http://example.com/'); - - expect(log, equals([new MethodCall('UrlLauncher.launch', 'http://example.com/')])); - }); -}