Commit 3ea34e99 authored by 汪林玲's avatar 汪林玲

增加null-safety

parent 371f06c4
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"install_plugin","path":"/Users/qiaomeng/Desktop/updadte/install_plugin/","dependencies":[]},{"name":"permission_handler","path":"/Users/qiaomeng/flutter_2.5.1/.pub-cache/hosted/pub.flutter-io.cn/permission_handler-3.3.0/","dependencies":[]}],"android":[{"name":"install_plugin","path":"/Users/qiaomeng/Desktop/updadte/install_plugin/","dependencies":[]},{"name":"permission_handler","path":"/Users/qiaomeng/flutter_2.5.1/.pub-cache/hosted/pub.flutter-io.cn/permission_handler-3.3.0/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"install_plugin","dependencies":[]},{"name":"permission_handler","dependencies":[]}],"date_created":"2021-10-16 14:52:48.255634","version":"2.5.1"}
\ No newline at end of file
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/qiaomeng/flutter_2.5.1"
export "FLUTTER_APPLICATION_PATH=/Users/qiaomeng/Desktop/updadte/install_plugin/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
......@@ -28,7 +28,7 @@ class _MyAppState extends State<MyApp> {
'apk file path to install. Like /storage/emulated/0/demo/update.apk'),
onChanged: (path) => _apkFilePath = path,
),
FlatButton(
TextButton(
onPressed: () {
onClickInstallApk();
},
......@@ -38,7 +38,7 @@ class _MyAppState extends State<MyApp> {
InputDecoration(hintText: 'URL for app store to launch'),
onChanged: (url) => _appUrl = url,
),
FlatButton(
TextButton(
onPressed: () => onClickGotoAppStore(_appUrl),
child: Text('gotoAppStore'))
],
......
......@@ -13,7 +13,7 @@ void main() {
testWidgets('Verify Widgets', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(new MyApp());
expect(find.byType(FlatButton), findsNWidgets(2));
expect(find.byType(TextButton), findsNWidgets(2));
});
}
......@@ -5,16 +5,11 @@ import 'package:flutter/services.dart';
class InstallPlugin {
static const MethodChannel _channel = const MethodChannel('install_plugin');
/// for Android : install apk by its file absolute path;
/// if the target platform is higher than android 24:
/// a [appId] is required
/// (the caller's applicationId which is defined in build.gradle)
static Future<String> installApk(String filePath, String appId) async {
Map<String, String> params = {'filePath': filePath, 'appId': appId};
return await _channel.invokeMethod('installApk', params);
}
/// for iOS: go to app store by the url
static Future<String> gotoAppStore(String urlString) async {
Map<String, String> params = {'urlString': urlString};
return await _channel.invokeMethod('gotoAppStore', params);
......
name: install_plugin
description: A flutter plugin for install apk for android; and using url to go to app store for iOS.
version: 2.0.1
author: akindone <akindone@163.com>
homepage: https://github.com/hui-z/flutter_install_plugin
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
plugin:
androidPackage: com.zaihui.installplugin
......
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:install_plugin/install_plugin.dart';
void main() {
const MethodChannel channel = MethodChannel('install_plugin');
final List<MethodCall> log = <MethodCall>[];
String response;
channel.setMockMethodCallHandler((MethodCall methodCall) async {
log.add(methodCall);
return response;
});
tearDown(() {
log.clear();
});
test('installApk test', () async {
response = 'Success';
final fakePath = 'fake.apk';
final fakeAppId = 'com.example.install';
final String result = await InstallPlugin.installApk(fakePath, fakeAppId);
expect(
log,
<Matcher>[isMethodCall('installApk', arguments: {'filePath': fakePath, 'appId': fakeAppId})],
);
expect(result, response);
});
test('gotoAppStore test', () async {
response = null;
final fakeUrl = 'fake_url';
final String result = await InstallPlugin.gotoAppStore(fakeUrl);
expect(
log,
<Matcher>[
isMethodCall('gotoAppStore', arguments: {'urlString': fakeUrl})
],
);
expect(result, isNull);
});
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment