From 05b01ae1346b8a840a34af78f42c485bf9ce561a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 18:53:49 +0200 Subject: [PATCH 01/21] Fix dependency versions --- packages/android_intent_plus/example/pubspec.yaml | 2 +- packages/android_intent_plus/pubspec.yaml | 2 +- packages/battery_plus/example/pubspec.yaml | 2 +- packages/battery_plus/pubspec.yaml | 2 +- packages/battery_plus_web/pubspec.yaml | 2 +- packages/connectivity_plus/example/pubspec.yaml | 2 +- packages/connectivity_plus/pubspec.yaml | 2 +- packages/connectivity_plus_web/pubspec.yaml | 2 +- packages/connectivity_plus_web/test/pubspec.yaml | 2 +- packages/device_info_plus/example/pubspec.yaml | 2 +- packages/device_info_plus_web/pubspec.yaml | 2 +- packages/package_info_plus/example/pubspec.yaml | 2 +- packages/package_info_plus/pubspec.yaml | 2 +- packages/sensors_plus/example/pubspec.yaml | 2 +- packages/sensors_plus/pubspec.yaml | 2 +- packages/sensors_plus_web/pubspec.yaml | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/android_intent_plus/example/pubspec.yaml b/packages/android_intent_plus/example/pubspec.yaml index f68ebd2324..4a6a7e9bed 100644 --- a/packages/android_intent_plus/example/pubspec.yaml +++ b/packages/android_intent_plus/example/pubspec.yaml @@ -8,7 +8,7 @@ dependencies: path: ../ dev_dependencies: - e2e: "^0.2.1" + e2e: ^0.3.0 flutter_driver: sdk: flutter pedantic: ^1.8.0 diff --git a/packages/android_intent_plus/pubspec.yaml b/packages/android_intent_plus/pubspec.yaml index 3038829a17..0443bd622e 100644 --- a/packages/android_intent_plus/pubspec.yaml +++ b/packages/android_intent_plus/pubspec.yaml @@ -15,7 +15,7 @@ flutter: dependencies: flutter: sdk: flutter - platform: ^2.0.0 + platform: ^3.0.0-nullsafety.2 meta: ^1.0.5 dev_dependencies: test: ^1.3.0 diff --git a/packages/battery_plus/example/pubspec.yaml b/packages/battery_plus/example/pubspec.yaml index 8a78c6b167..f71f7ef961 100644 --- a/packages/battery_plus/example/pubspec.yaml +++ b/packages/battery_plus/example/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: dev_dependencies: flutter_driver: sdk: flutter - integration_test: ^0.8.0 + integration_test: ^0.9.1 pedantic: ^1.9.0 flutter: diff --git a/packages/battery_plus/pubspec.yaml b/packages/battery_plus/pubspec.yaml index efe15dc1ea..9d4f203bf5 100644 --- a/packages/battery_plus/pubspec.yaml +++ b/packages/battery_plus/pubspec.yaml @@ -29,7 +29,7 @@ dev_dependencies: mockito: 3.0.0 flutter_test: sdk: flutter - integration_test: ^0.8.0 + integration_test: ^0.9.1 plugin_platform_interface: ^1.0.0 pedantic: ^1.9.0 diff --git a/packages/battery_plus_web/pubspec.yaml b/packages/battery_plus_web/pubspec.yaml index 26b476e811..251c752290 100644 --- a/packages/battery_plus_web/pubspec.yaml +++ b/packages/battery_plus_web/pubspec.yaml @@ -24,7 +24,7 @@ dev_dependencies: sdk: flutter flutter_test: sdk: flutter - integration_test: ^0.9.0 + integration_test: ^0.9.1 mockito: ^4.1.2 environment: diff --git a/packages/connectivity_plus/example/pubspec.yaml b/packages/connectivity_plus/example/pubspec.yaml index 097ecc20a8..3fd6f68a89 100644 --- a/packages/connectivity_plus/example/pubspec.yaml +++ b/packages/connectivity_plus/example/pubspec.yaml @@ -11,7 +11,7 @@ dev_dependencies: flutter_driver: sdk: flutter test: any - integration_test: ^0.8.0 + integration_test: ^0.9.1 pedantic: ^1.8.0 flutter: diff --git a/packages/connectivity_plus/pubspec.yaml b/packages/connectivity_plus/pubspec.yaml index db7f5677c3..48fdf61665 100644 --- a/packages/connectivity_plus/pubspec.yaml +++ b/packages/connectivity_plus/pubspec.yaml @@ -33,7 +33,7 @@ dev_dependencies: flutter_driver: sdk: flutter test: any - integration_test: ^0.8.0 + integration_test: ^0.9.1 mockito: ^4.1.1 plugin_platform_interface: ^1.0.0 pedantic: ^1.8.0 diff --git a/packages/connectivity_plus_web/pubspec.yaml b/packages/connectivity_plus_web/pubspec.yaml index 55b0f3621c..62a222f76d 100644 --- a/packages/connectivity_plus_web/pubspec.yaml +++ b/packages/connectivity_plus_web/pubspec.yaml @@ -24,7 +24,7 @@ dev_dependencies: sdk: flutter flutter_test: sdk: flutter - integration_test: ^0.8.0 + integration_test: ^0.9.1 mockito: ^4.1.1 environment: diff --git a/packages/connectivity_plus_web/test/pubspec.yaml b/packages/connectivity_plus_web/test/pubspec.yaml index 83658741a6..b6b7d58ec1 100644 --- a/packages/connectivity_plus_web/test/pubspec.yaml +++ b/packages/connectivity_plus_web/test/pubspec.yaml @@ -16,7 +16,7 @@ dev_dependencies: sdk: flutter flutter_driver: sdk: flutter - integration_test: ^0.8.0 + integration_test: ^0.9.1 mockito: ^4.1.1 environment: diff --git a/packages/device_info_plus/example/pubspec.yaml b/packages/device_info_plus/example/pubspec.yaml index 21fb303b69..ced252c1c2 100644 --- a/packages/device_info_plus/example/pubspec.yaml +++ b/packages/device_info_plus/example/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: dev_dependencies: flutter_driver: sdk: flutter - integration_test: ^0.8.0 + integration_test: ^0.9.1 pedantic: ^1.8.0 flutter: diff --git a/packages/device_info_plus_web/pubspec.yaml b/packages/device_info_plus_web/pubspec.yaml index 5d3d10a092..61a042bbca 100644 --- a/packages/device_info_plus_web/pubspec.yaml +++ b/packages/device_info_plus_web/pubspec.yaml @@ -24,7 +24,7 @@ dev_dependencies: sdk: flutter flutter_test: sdk: flutter - integration_test: ^0.9.0 + integration_test: ^0.9.1 mockito: ^4.1.2 environment: diff --git a/packages/package_info_plus/example/pubspec.yaml b/packages/package_info_plus/example/pubspec.yaml index 9cd135d3d0..ddacb6a0c1 100644 --- a/packages/package_info_plus/example/pubspec.yaml +++ b/packages/package_info_plus/example/pubspec.yaml @@ -5,7 +5,7 @@ dependencies: sdk: flutter package_info_plus: path: ../ - integration_test: ^0.8.0 + integration_test: ^0.9.1 universal_io: ^1.0.1 dev_dependencies: diff --git a/packages/package_info_plus/pubspec.yaml b/packages/package_info_plus/pubspec.yaml index bf166980a0..87e2bc7a39 100644 --- a/packages/package_info_plus/pubspec.yaml +++ b/packages/package_info_plus/pubspec.yaml @@ -32,7 +32,7 @@ dev_dependencies: flutter_driver: sdk: flutter test: any - integration_test: ^0.8.0 + integration_test: ^0.9.1 pedantic: ^1.8.0 environment: diff --git a/packages/sensors_plus/example/pubspec.yaml b/packages/sensors_plus/example/pubspec.yaml index c3f2e4d3bd..c76714ddbf 100644 --- a/packages/sensors_plus/example/pubspec.yaml +++ b/packages/sensors_plus/example/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: dev_dependencies: flutter_driver: sdk: flutter - integration_test: ^0.8.0 + integration_test: ^0.9.1 pedantic: ^1.8.0 flutter: diff --git a/packages/sensors_plus/pubspec.yaml b/packages/sensors_plus/pubspec.yaml index 4e609ef49f..11bb9e4ee3 100644 --- a/packages/sensors_plus/pubspec.yaml +++ b/packages/sensors_plus/pubspec.yaml @@ -26,7 +26,7 @@ dev_dependencies: test: ^1.3.0 flutter_test: sdk: flutter - integration_test: ^0.8.0 + integration_test: ^0.9.1 mockito: ^4.1.1 pedantic: ^1.8.0 diff --git a/packages/sensors_plus_web/pubspec.yaml b/packages/sensors_plus_web/pubspec.yaml index 5067d6eb09..1ee5687822 100644 --- a/packages/sensors_plus_web/pubspec.yaml +++ b/packages/sensors_plus_web/pubspec.yaml @@ -28,5 +28,5 @@ dev_dependencies: sdk: flutter flutter_test: sdk: flutter - integration_test: ^0.9.0 + integration_test: ^0.9.1 mockito: ^4.1.2 From 9d13eca688a6bc85315be37f65e8b319a4e189f9 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 19:13:24 +0200 Subject: [PATCH 02/21] Fix tests to pass --- packages/share_plus/pubspec.yaml | 1 + packages/share_plus/test/{share_e2e.dart => share_test.dart} | 0 2 files changed, 1 insertion(+) rename packages/share_plus/test/{share_e2e.dart => share_test.dart} (100%) diff --git a/packages/share_plus/pubspec.yaml b/packages/share_plus/pubspec.yaml index 796078775f..6fce09da32 100644 --- a/packages/share_plus/pubspec.yaml +++ b/packages/share_plus/pubspec.yaml @@ -32,6 +32,7 @@ dev_dependencies: sdk: flutter integration_test: ^0.9.1 pedantic: ^1.8.0 + url_launcher: ^5.7.2 environment: sdk: ">=2.1.0 <3.0.0" diff --git a/packages/share_plus/test/share_e2e.dart b/packages/share_plus/test/share_test.dart similarity index 100% rename from packages/share_plus/test/share_e2e.dart rename to packages/share_plus/test/share_test.dart From 613ce537e79675c6b5ae09558b60281dc4638a43 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 19:14:54 +0200 Subject: [PATCH 03/21] Run melos format --- .../BackgroundExecutionTest.java | 10 ++--- .../example/lib/main_espresso.dart | 2 +- .../android_alarm_manager_e2e.dart | 9 ++-- .../android_alarm_manager_e2e_test.dart | 2 +- .../test/android_alarm_manager_test.dart | 41 ++++++++++++++----- .../ios/Classes/FLTConnectivityPlugin.m | 4 +- .../flutter/generated_plugin_registrant.cc | 4 +- .../device_info_plus/example/linux/main.cc | 3 +- .../example/linux/my_application.cc | 7 ++-- .../method_channel_device_info.dart | 3 +- .../example/test_driver/package_info_e2e.dart | 15 +++---- .../lib/package_info_macos.dart | 2 +- .../method_channel_package_info_test.dart | 30 +++++++------- packages/sensors_plus/example/lib/snake.dart | 3 +- packages/sensors_plus/lib/src/sensors.dart | 1 - packages/sensors_plus/test/sensors_test.dart | 3 +- .../sensors_plus_web/lib/src/sensors.dart | 2 +- .../flutter/generated_plugin_registrant.cc | 3 +- packages/share_plus/example/linux/main.cc | 3 +- .../example/linux/my_application.cc | 7 ++-- .../example/windows/runner/resource.h | 10 ++--- .../example/windows/runner/run_loop.h | 6 +-- .../example/windows/runner/win32_window.cpp | 18 +++----- .../example/windows/runner/win32_window.h | 9 ++-- .../share_plus_platform_interface_test.dart | 3 +- 25 files changed, 103 insertions(+), 97 deletions(-) diff --git a/packages/android_alarm_manager_plus/example/android/app/src/androidTest/java/io/flutter/plugins/androidalarmmanager/BackgroundExecutionTest.java b/packages/android_alarm_manager_plus/example/android/app/src/androidTest/java/io/flutter/plugins/androidalarmmanager/BackgroundExecutionTest.java index 7f4954c40f..760f0f705c 100644 --- a/packages/android_alarm_manager_plus/example/android/app/src/androidTest/java/io/flutter/plugins/androidalarmmanager/BackgroundExecutionTest.java +++ b/packages/android_alarm_manager_plus/example/android/app/src/androidTest/java/io/flutter/plugins/androidalarmmanager/BackgroundExecutionTest.java @@ -4,7 +4,6 @@ package io.flutter.plugins.androidalarmmanager; -import static androidx.test.espresso.Espresso.pressBackUnconditionally; import static androidx.test.espresso.flutter.EspressoFlutter.onFlutterWidget; import static androidx.test.espresso.flutter.action.FlutterActions.click; import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withValueKey; @@ -13,14 +12,11 @@ import android.content.Context; import android.content.SharedPreferences; import android.util.Log; - import androidx.test.InstrumentationRegistry; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.rule.ActivityTestRule; - import com.example.example.MainActivity; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -50,7 +46,7 @@ public void setUp() throws Exception { @Test public void startBackgroundIsolate() throws Exception { - Log.d("BackgroundExecutionTest","Started"); + Log.d("BackgroundExecutionTest", "Started"); // Register a one shot alarm which will go off in ~5 seconds. onFlutterWidget(withValueKey("RegisterOneShotAlarm")).perform(click()); @@ -71,9 +67,9 @@ public void startBackgroundIsolate() throws Exception { while ((prefs.getLong(COUNT_KEY, -1) == 0) && (tries < 200)) { Thread.sleep(100); ++tries; - Log.d("BackgroundExecutionTest","Waiting..."); + Log.d("BackgroundExecutionTest", "Waiting..."); } assertEquals(prefs.getLong(COUNT_KEY, -1), 1); - Log.d("BackgroundExecutionTest","Finished"); + Log.d("BackgroundExecutionTest", "Finished"); } } diff --git a/packages/android_alarm_manager_plus/example/lib/main_espresso.dart b/packages/android_alarm_manager_plus/example/lib/main_espresso.dart index f892c656c3..98ed00b2c6 100644 --- a/packages/android_alarm_manager_plus/example/lib/main_espresso.dart +++ b/packages/android_alarm_manager_plus/example/lib/main_espresso.dart @@ -8,4 +8,4 @@ import 'package:android_alarm_manager_example/main.dart' as app; void main() { enableFlutterDriverExtension(); app.main(); -} \ No newline at end of file +} diff --git a/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e.dart b/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e.dart index 5f52208140..7d57df6c22 100644 --- a/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e.dart +++ b/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e.dart @@ -66,7 +66,8 @@ void main() { final alarmId = 0; final startingValue = await readCounter(); debugPrint('oneShot start'); - await AndroidAlarmManager.oneShot(const Duration(seconds: 1), alarmId, incrementCounter); + await AndroidAlarmManager.oneShot( + const Duration(seconds: 1), alarmId, incrementCounter); debugPrint('oneShot end'); debugPrint('Canceling alarm...'); expect(await AndroidAlarmManager.cancel(alarmId), isTrue); @@ -80,7 +81,8 @@ void main() { final alarmId = 1; final startingValue = await readCounter(); debugPrint('oneShot start'); - await AndroidAlarmManager.oneShot(const Duration(seconds: 1), alarmId, incrementCounter, + await AndroidAlarmManager.oneShot( + const Duration(seconds: 1), alarmId, incrementCounter, exact: true, wakeup: true); debugPrint('oneShot end'); await Future.delayed(const Duration(seconds: 2)); @@ -100,7 +102,8 @@ void main() { testWidgets('periodic', (WidgetTester tester) async { final alarmId = 2; final startingValue = await readCounter(); - await AndroidAlarmManager.periodic(const Duration(seconds: 1), alarmId, incrementCounter, + await AndroidAlarmManager.periodic( + const Duration(seconds: 1), alarmId, incrementCounter, wakeup: true, exact: true); // poll until file is updated while (await readCounter() < startingValue + 2) { diff --git a/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e_test.dart b/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e_test.dart index 3779ab2a0e..8373a3afd1 100644 --- a/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e_test.dart +++ b/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e_test.dart @@ -22,7 +22,7 @@ Future> resumeIsolatesOnPause( return driver.serviceClient.onIsolateRunnable .asBroadcastStream() .listen((VMIsolateRef isolateRef) async { - print('onIsolateRunnable'); + print('onIsolateRunnable'); final isolate = await isolateRef.load(); if (isolate.isPaused) { print('isolate.resume'); diff --git a/packages/android_alarm_manager_plus/test/android_alarm_manager_test.dart b/packages/android_alarm_manager_plus/test/android_alarm_manager_test.dart index d58fd21442..60cf8bb7c5 100644 --- a/packages/android_alarm_manager_plus/test/android_alarm_manager_test.dart +++ b/packages/android_alarm_manager_plus/test/android_alarm_manager_test.dart @@ -12,7 +12,8 @@ void main() { String invalidCallback(String foo) => foo; void validCallback(int id) => null; - const testChannel = MethodChannel('plugins.flutter.io/android_alarm_manager', JSONMethodCodec()); + const testChannel = MethodChannel( + 'plugins.flutter.io/android_alarm_manager', JSONMethodCodec()); TestWidgetsFlutterBinding.ensureInitialized(); setUpAll(() { @@ -36,17 +37,24 @@ void main() { final validId = 1; // Callback should take a single int param. - await expectLater(() => AndroidAlarmManager.oneShotAt(validTime, validId, invalidCallback), throwsAssertionError); + await expectLater( + () => AndroidAlarmManager.oneShotAt( + validTime, validId, invalidCallback), + throwsAssertionError); // ID should be less than 32 bits. await expectLater( - () => AndroidAlarmManager.oneShotAt(validTime, 2147483648, validCallback), throwsAssertionError); + () => AndroidAlarmManager.oneShotAt( + validTime, 2147483648, validCallback), + throwsAssertionError); }); test('sends arguments to the platform', () async { final alarm = DateTime(1993); const rawHandle = 4; - AndroidAlarmManager.setTestOverides(getCallbackHandle: (Function _) => CallbackHandle.fromRawHandle(rawHandle)); + AndroidAlarmManager.setTestOverides( + getCallbackHandle: (Function _) => + CallbackHandle.fromRawHandle(rawHandle)); final id = 1; final alarmClock = true; @@ -68,7 +76,8 @@ void main() { return true; }); - final result = await AndroidAlarmManager.oneShotAt(alarm, id, validCallback, + final result = await AndroidAlarmManager.oneShotAt( + alarm, id, validCallback, alarmClock: alarmClock, allowWhileIdle: allowWhileIdle, exact: exact, @@ -83,7 +92,9 @@ void main() { final now = DateTime(1993); const rawHandle = 4; AndroidAlarmManager.setTestOverides( - now: () => now, getCallbackHandle: (Function _) => CallbackHandle.fromRawHandle(rawHandle)); + now: () => now, + getCallbackHandle: (Function _) => + CallbackHandle.fromRawHandle(rawHandle)); const alarm = Duration(seconds: 1); final id = 1; @@ -100,7 +111,8 @@ void main() { expect(call.arguments[2], allowWhileIdle); expect(call.arguments[3], exact); expect(call.arguments[4], wakeup); - expect(call.arguments[5], now.millisecondsSinceEpoch + alarm.inMilliseconds); + expect( + call.arguments[5], now.millisecondsSinceEpoch + alarm.inMilliseconds); expect(call.arguments[6], rescheduleOnReboot); expect(call.arguments[7], rawHandle); return true; @@ -123,18 +135,24 @@ void main() { // Callback should take a single int param. await expectLater( - () => AndroidAlarmManager.periodic(validDuration, validId, invalidCallback), throwsAssertionError); + () => AndroidAlarmManager.periodic( + validDuration, validId, invalidCallback), + throwsAssertionError); // ID should be less than 32 bits. await expectLater( - () => AndroidAlarmManager.periodic(validDuration, 2147483648, validCallback), throwsAssertionError); + () => AndroidAlarmManager.periodic( + validDuration, 2147483648, validCallback), + throwsAssertionError); }); test('sends arguments through to the platform', () async { final now = DateTime(1993); const rawHandle = 4; AndroidAlarmManager.setTestOverides( - now: () => now, getCallbackHandle: (Function _) => CallbackHandle.fromRawHandle(rawHandle)); + now: () => now, + getCallbackHandle: (Function _) => + CallbackHandle.fromRawHandle(rawHandle)); final id = 1; final exact = true; @@ -147,7 +165,8 @@ void main() { expect(call.arguments[0], id); expect(call.arguments[1], exact); expect(call.arguments[2], wakeup); - expect(call.arguments[3], (now.millisecondsSinceEpoch + period.inMilliseconds)); + expect(call.arguments[3], + (now.millisecondsSinceEpoch + period.inMilliseconds)); expect(call.arguments[4], period.inMilliseconds); expect(call.arguments[5], rescheduleOnReboot); expect(call.arguments[6], rawHandle); diff --git a/packages/connectivity_plus/ios/Classes/FLTConnectivityPlugin.m b/packages/connectivity_plus/ios/Classes/FLTConnectivityPlugin.m index 526bee25d5..0a65409b38 100644 --- a/packages/connectivity_plus/ios/Classes/FLTConnectivityPlugin.m +++ b/packages/connectivity_plus/ios/Classes/FLTConnectivityPlugin.m @@ -156,7 +156,9 @@ - (NSString*)convertCLAuthorizationStatusToString:(CLAuthorizationStatus)status case kCLAuthorizationStatusAuthorizedWhenInUse: { return @"authorizedWhenInUse"; } - default: { return @"unknown"; } + default: { + return @"unknown"; + } } } diff --git a/packages/device_info_plus/example/linux/flutter/generated_plugin_registrant.cc b/packages/device_info_plus/example/linux/flutter/generated_plugin_registrant.cc index d38195aa04..890de29bba 100644 --- a/packages/device_info_plus/example/linux/flutter/generated_plugin_registrant.cc +++ b/packages/device_info_plus/example/linux/flutter/generated_plugin_registrant.cc @@ -4,6 +4,4 @@ #include "generated_plugin_registrant.h" - -void fl_register_plugins(FlPluginRegistry* registry) { -} +void fl_register_plugins(FlPluginRegistry* registry) {} diff --git a/packages/device_info_plus/example/linux/main.cc b/packages/device_info_plus/example/linux/main.cc index 058e6178fe..10835acb58 100644 --- a/packages/device_info_plus/example/linux/main.cc +++ b/packages/device_info_plus/example/linux/main.cc @@ -2,7 +2,8 @@ int main(int argc, char** argv) { // Only X11 is currently supported. - // Wayland support is being developed: https://github.com/flutter/flutter/issues/57932. + // Wayland support is being developed: + // https://github.com/flutter/flutter/issues/57932. gdk_set_allowed_backends("x11"); g_autoptr(MyApplication) app = my_application_new(); diff --git a/packages/device_info_plus/example/linux/my_application.cc b/packages/device_info_plus/example/linux/my_application.cc index f28ca30940..67ed0b9025 100644 --- a/packages/device_info_plus/example/linux/my_application.cc +++ b/packages/device_info_plus/example/linux/my_application.cc @@ -14,7 +14,7 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) static void my_application_activate(GApplication* application) { GtkWindow* window = GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); - GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); gtk_widget_show(GTK_WIDGET(header_bar)); gtk_header_bar_set_title(header_bar, "example"); gtk_header_bar_set_show_close_button(header_bar, TRUE); @@ -40,7 +40,6 @@ static void my_application_class_init(MyApplicationClass* klass) { static void my_application_init(MyApplication* self) {} MyApplication* my_application_new() { - return MY_APPLICATION(g_object_new(my_application_get_type(), - "application-id", APPLICATION_ID, - nullptr)); + return MY_APPLICATION(g_object_new( + my_application_get_type(), "application-id", APPLICATION_ID, nullptr)); } diff --git a/packages/device_info_plus_platform_interface/lib/method_channel/method_channel_device_info.dart b/packages/device_info_plus_platform_interface/lib/method_channel/method_channel_device_info.dart index 3d10b1091c..9907b32f0e 100644 --- a/packages/device_info_plus_platform_interface/lib/method_channel/method_channel_device_info.dart +++ b/packages/device_info_plus_platform_interface/lib/method_channel/method_channel_device_info.dart @@ -14,7 +14,8 @@ class MethodChannelDeviceInfo extends DeviceInfoPlatform { // Method channel for Android devices Future androidInfo() async { return AndroidDeviceInfo.fromMap( - (await channel.invokeMethod('getAndroidDeviceInfo')).cast(), + (await channel.invokeMethod('getAndroidDeviceInfo')) + .cast(), ); } diff --git a/packages/package_info_plus/example/test_driver/package_info_e2e.dart b/packages/package_info_plus/example/test_driver/package_info_e2e.dart index ee81ebdd67..ac1468834d 100644 --- a/packages/package_info_plus/example/test_driver/package_info_e2e.dart +++ b/packages/package_info_plus/example/test_driver/package_info_e2e.dart @@ -9,7 +9,6 @@ import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_example/main.dart'; import 'package:universal_io/io.dart'; - void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); @@ -33,9 +32,9 @@ void main() { expect(info.version, '1.0.0'); } else if (kIsWeb) { expect(info.appName, 'package_info_example'); - expect(info.buildNumber,null); + expect(info.buildNumber, null); expect(info.packageName, null); - expect(info.version,null); + expect(info.version, null); } else { throw (UnsupportedError('platform not supported')); } @@ -62,12 +61,10 @@ void main() { expect( find.text('io.flutter.plugins.packageInfoExample'), findsOneWidget); expect(find.text('1.0.0'), findsOneWidget); - } else if(kIsWeb) - { - expect(find.text('package_info_example'), findsOneWidget); - expect(find.text('Not set'),findsNWidgets(3)); - } - else { + } else if (kIsWeb) { + expect(find.text('package_info_example'), findsOneWidget); + expect(find.text('Not set'), findsNWidgets(3)); + } else { throw (UnsupportedError('platform not supported')); } }); diff --git a/packages/package_info_plus_macos/lib/package_info_macos.dart b/packages/package_info_plus_macos/lib/package_info_macos.dart index f1c5fb7a3e..4fd56c7b76 100644 --- a/packages/package_info_plus_macos/lib/package_info_macos.dart +++ b/packages/package_info_plus_macos/lib/package_info_macos.dart @@ -1,3 +1,3 @@ // The package_info_platform_interface defaults to MethodChannelPackageInfo // as its instance, which is all the macOS implementation needs. This file -// is here to silence warnings when publishing to pub. \ No newline at end of file +// is here to silence warnings when publishing to pub. diff --git a/packages/package_info_plus_platform_interface/test/method_channel_package_info_test.dart b/packages/package_info_plus_platform_interface/test/method_channel_package_info_test.dart index 13df1b6944..84e34efbd5 100644 --- a/packages/package_info_plus_platform_interface/test/method_channel_package_info_test.dart +++ b/packages/package_info_plus_platform_interface/test/method_channel_package_info_test.dart @@ -38,21 +38,21 @@ void main() { const MethodChannel channel = MethodChannel('plugins.flutter.io/package_info'); final List log = []; - channel.setMockMethodCallHandler((MethodCall methodCall) async { - log.add(methodCall); - switch (methodCall.method) { - case 'getAll': - return { - 'appName': 'package_info_example', - 'buildNumber': '1', - 'packageName': 'io.flutter.plugins.packageinfoexample', - 'version': '1.0', - }; - default: - assert(false); - return null; - } - }); + channel.setMockMethodCallHandler((MethodCall methodCall) async { + log.add(methodCall); + switch (methodCall.method) { + case 'getAll': + return { + 'appName': 'package_info_example', + 'buildNumber': '1', + 'packageName': 'io.flutter.plugins.packageinfoexample', + 'version': '1.0', + }; + default: + assert(false); + return null; + } + }); final MethodChannelPackageInfo packageInfo = MethodChannelPackageInfo(); diff --git a/packages/sensors_plus/example/lib/snake.dart b/packages/sensors_plus/example/lib/snake.dart index ba46cfc24b..2a3de4457d 100644 --- a/packages/sensors_plus/example/lib/snake.dart +++ b/packages/sensors_plus/example/lib/snake.dart @@ -81,7 +81,8 @@ class SnakeState extends State { @override void initState() { super.initState(); - _streamSubscription = accelerometerEvents.listen((AccelerometerEvent event) { + _streamSubscription = + accelerometerEvents.listen((AccelerometerEvent event) { setState(() { acceleration = event; }); diff --git a/packages/sensors_plus/lib/src/sensors.dart b/packages/sensors_plus/lib/src/sensors.dart index d4b9e9958f..9a5aafae3b 100644 --- a/packages/sensors_plus/lib/src/sensors.dart +++ b/packages/sensors_plus/lib/src/sensors.dart @@ -1,6 +1,5 @@ import 'package:sensors_plus_platform_interface/sensors_plus_platform_interface.dart'; - class Sensors extends SensorsPlatform { /// Constructs a singleton instance of [Sensors]. /// diff --git a/packages/sensors_plus/test/sensors_test.dart b/packages/sensors_plus/test/sensors_test.dart index bd31a7ca4c..009bc3435e 100644 --- a/packages/sensors_plus/test/sensors_test.dart +++ b/packages/sensors_plus/test/sensors_test.dart @@ -60,7 +60,8 @@ void _initializeFakeSensorChannel(String channelName, List sensorData) { ); } - ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(channelName, (ByteData message) async { + ServicesBinding.instance.defaultBinaryMessenger + .setMockMessageHandler(channelName, (ByteData message) async { final MethodCall methodCall = standardMethod.decodeMethodCall(message); if (methodCall.method == 'listen') { _emitEvent(standardMethod.encodeSuccessEnvelope(sensorData)); diff --git a/packages/sensors_plus_web/lib/src/sensors.dart b/packages/sensors_plus_web/lib/src/sensors.dart index 230f3775c7..7a20499a09 100644 --- a/packages/sensors_plus_web/lib/src/sensors.dart +++ b/packages/sensors_plus_web/lib/src/sensors.dart @@ -19,7 +19,7 @@ class SensorsPlugin extends SensorsPlatform { String apiName, String premissionName, Function onError, - }) { + }) { try { initSensor(); } catch (error) { diff --git a/packages/share_plus/example/linux/flutter/generated_plugin_registrant.cc b/packages/share_plus/example/linux/flutter/generated_plugin_registrant.cc index 026851fa2f..36185a63f2 100644 --- a/packages/share_plus/example/linux/flutter/generated_plugin_registrant.cc +++ b/packages/share_plus/example/linux/flutter/generated_plugin_registrant.cc @@ -8,6 +8,7 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + fl_plugin_registry_get_registrar_for_plugin(registry, + "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/packages/share_plus/example/linux/main.cc b/packages/share_plus/example/linux/main.cc index 058e6178fe..10835acb58 100644 --- a/packages/share_plus/example/linux/main.cc +++ b/packages/share_plus/example/linux/main.cc @@ -2,7 +2,8 @@ int main(int argc, char** argv) { // Only X11 is currently supported. - // Wayland support is being developed: https://github.com/flutter/flutter/issues/57932. + // Wayland support is being developed: + // https://github.com/flutter/flutter/issues/57932. gdk_set_allowed_backends("x11"); g_autoptr(MyApplication) app = my_application_new(); diff --git a/packages/share_plus/example/linux/my_application.cc b/packages/share_plus/example/linux/my_application.cc index f28ca30940..67ed0b9025 100644 --- a/packages/share_plus/example/linux/my_application.cc +++ b/packages/share_plus/example/linux/my_application.cc @@ -14,7 +14,7 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) static void my_application_activate(GApplication* application) { GtkWindow* window = GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); - GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); gtk_widget_show(GTK_WIDGET(header_bar)); gtk_header_bar_set_title(header_bar, "example"); gtk_header_bar_set_show_close_button(header_bar, TRUE); @@ -40,7 +40,6 @@ static void my_application_class_init(MyApplicationClass* klass) { static void my_application_init(MyApplication* self) {} MyApplication* my_application_new() { - return MY_APPLICATION(g_object_new(my_application_get_type(), - "application-id", APPLICATION_ID, - nullptr)); + return MY_APPLICATION(g_object_new( + my_application_get_type(), "application-id", APPLICATION_ID, nullptr)); } diff --git a/packages/share_plus/example/windows/runner/resource.h b/packages/share_plus/example/windows/runner/resource.h index 66a65d1e4a..d5d958dc42 100644 --- a/packages/share_plus/example/windows/runner/resource.h +++ b/packages/share_plus/example/windows/runner/resource.h @@ -2,15 +2,15 @@ // Microsoft Visual C++ generated include file. // Used by Runner.rc // -#define IDI_APP_ICON 101 +#define IDI_APP_ICON 101 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/packages/share_plus/example/windows/runner/run_loop.h b/packages/share_plus/example/windows/runner/run_loop.h index 000d362463..5f2c4a9ad7 100644 --- a/packages/share_plus/example/windows/runner/run_loop.h +++ b/packages/share_plus/example/windows/runner/run_loop.h @@ -21,12 +21,10 @@ class RunLoop { void Run(); // Registers the given Flutter instance for event servicing. - void RegisterFlutterInstance( - flutter::FlutterEngine* flutter_instance); + void RegisterFlutterInstance(flutter::FlutterEngine* flutter_instance); // Unregisters the given Flutter instance from event servicing. - void UnregisterFlutterInstance( - flutter::FlutterEngine* flutter_instance); + void UnregisterFlutterInstance(flutter::FlutterEngine* flutter_instance); private: using TimePoint = std::chrono::steady_clock::time_point; diff --git a/packages/share_plus/example/windows/runner/win32_window.cpp b/packages/share_plus/example/windows/runner/win32_window.cpp index efc3eb9f22..c63ad013b0 100644 --- a/packages/share_plus/example/windows/runner/win32_window.cpp +++ b/packages/share_plus/example/windows/runner/win32_window.cpp @@ -93,17 +93,14 @@ void WindowClassRegistrar::UnregisterWindowClass() { class_registered_ = false; } -Win32Window::Win32Window() { - ++g_active_window_count; -} +Win32Window::Win32Window() { ++g_active_window_count; } Win32Window::~Win32Window() { --g_active_window_count; Destroy(); } -bool Win32Window::CreateAndShow(const std::wstring& title, - const Point& origin, +bool Win32Window::CreateAndShow(const std::wstring& title, const Point& origin, const Size& size) { Destroy(); @@ -130,8 +127,7 @@ bool Win32Window::CreateAndShow(const std::wstring& title, } // static -LRESULT CALLBACK Win32Window::WndProc(HWND const window, - UINT const message, +LRESULT CALLBACK Win32Window::WndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept { if (message == WM_NCCREATE) { @@ -150,9 +146,7 @@ LRESULT CALLBACK Win32Window::WndProc(HWND const window, } LRESULT -Win32Window::MessageHandler(HWND hwnd, - UINT const message, - WPARAM const wparam, +Win32Window::MessageHandler(HWND hwnd, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept { switch (message) { case WM_DESTROY: @@ -226,9 +220,7 @@ RECT Win32Window::GetClientArea() { return frame; } -HWND Win32Window::GetHandle() { - return window_handle_; -} +HWND Win32Window::GetHandle() { return window_handle_; } void Win32Window::SetQuitOnClose(bool quit_on_close) { quit_on_close_ = quit_on_close; diff --git a/packages/share_plus/example/windows/runner/win32_window.h b/packages/share_plus/example/windows/runner/win32_window.h index 17ba431125..4ae64a12b4 100644 --- a/packages/share_plus/example/windows/runner/win32_window.h +++ b/packages/share_plus/example/windows/runner/win32_window.h @@ -34,8 +34,7 @@ class Win32Window { // consistent size to will treat the width height passed in to this function // as logical pixels and scale to appropriate for the default monitor. Returns // true if the window was created successfully. - bool CreateAndShow(const std::wstring& title, - const Point& origin, + bool CreateAndShow(const std::wstring& title, const Point& origin, const Size& size); // Release OS resources associated with window. @@ -58,8 +57,7 @@ class Win32Window { // Processes and route salient window messages for mouse handling, // size change and DPI. Delegates handling of these to member overloads that // inheriting classes can handle. - virtual LRESULT MessageHandler(HWND window, - UINT const message, + virtual LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept; @@ -78,8 +76,7 @@ class Win32Window { // non-client DPI scaling so that the non-client area automatically // responsponds to changes in DPI. All other messages are handled by // MessageHandler. - static LRESULT CALLBACK WndProc(HWND const window, - UINT const message, + static LRESULT CALLBACK WndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept; diff --git a/packages/share_plus_platform_interface/test/share_plus_platform_interface_test.dart b/packages/share_plus_platform_interface/test/share_plus_platform_interface_test.dart index efd60c4974..b6d7930294 100644 --- a/packages/share_plus_platform_interface/test/share_plus_platform_interface_test.dart +++ b/packages/share_plus_platform_interface/test/share_plus_platform_interface_test.dart @@ -21,7 +21,8 @@ void main() { setUp(() { mockChannel = MockMethodChannel(); // Re-pipe to mockito for easier verifies. - MethodChannelShare.channel.setMockMethodCallHandler((MethodCall call) async { + MethodChannelShare.channel + .setMockMethodCallHandler((MethodCall call) async { // The explicit type can be void as the only method call has a return type of void. await mockChannel.invokeMethod(call.method, call.arguments); }); From 2f136cbe031382499e7457b801fad034bf18623b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 19:28:58 +0200 Subject: [PATCH 04/21] Add missing docs --- packages/battery_plus_platform_interface/lib/src/utils.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/battery_plus_platform_interface/lib/src/utils.dart b/packages/battery_plus_platform_interface/lib/src/utils.dart index a6a13ac891..cb5c291216 100644 --- a/packages/battery_plus_platform_interface/lib/src/utils.dart +++ b/packages/battery_plus_platform_interface/lib/src/utils.dart @@ -1,5 +1,6 @@ import 'enums.dart'; +/// Method for parsing battery state. BatteryState parseBatteryState(String state) { switch (state) { case 'full': From 9464255e46d575838c0300a84100b44e68a132f5 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 19:40:15 +0200 Subject: [PATCH 05/21] device_info_example: remove pointless test failing analysis --- .../example/test/widget_test.dart | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 packages/device_info_plus/example/test/widget_test.dart diff --git a/packages/device_info_plus/example/test/widget_test.dart b/packages/device_info_plus/example/test/widget_test.dart deleted file mode 100644 index dd5db9033e..0000000000 --- a/packages/device_info_plus/example/test/widget_test.dart +++ /dev/null @@ -1,18 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:device_info_example/main.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - testWidgets('Initial battery value smoke test', (WidgetTester tester) async { - // // Build our app and trigger a frame. - // await tester.pumpWidget(MyApp()); - - // expect(find.text('name'), findsOneWidget); - }); -} From 13ce56add086c0f828d6485bfb0b9316d50a2f43 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 19:59:55 +0200 Subject: [PATCH 06/21] Add missing docs to make `melos run analyze` pass --- .../battery_plus_web/lib/battery_web.dart | 1 + .../lib/model/linux_device_info.dart | 1 + .../lib/model/web_browser_info.dart | 49 ++++++++++++------- .../lib/device_info_plus_web.dart | 1 + .../lib/package_info_data.dart | 1 + packages/sensors_plus/lib/src/sensors.dart | 4 ++ .../lib/sensors_plus_platform_interface.dart | 1 + .../lib/src/method_channel_sensors.dart | 1 + .../sensors_plus_web/lib/src/sensors.dart | 2 +- 9 files changed, 42 insertions(+), 19 deletions(-) diff --git a/packages/battery_plus_web/lib/battery_web.dart b/packages/battery_plus_web/lib/battery_web.dart index b6fc17de3e..b07830bae1 100644 --- a/packages/battery_plus_web/lib/battery_web.dart +++ b/packages/battery_plus_web/lib/battery_web.dart @@ -7,6 +7,7 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; /// The web implementation of the BatteryPlatform of the Battery plugin. class BatteryPlugin extends BatteryPlatform { + /// Constructs a BatteryPlugin. BatteryPlugin(html.Navigator navigator) : _getBattery = navigator.getBattery; /// A check to determine if this version of the plugin can be used. diff --git a/packages/device_info_plus_platform_interface/lib/model/linux_device_info.dart b/packages/device_info_plus_platform_interface/lib/model/linux_device_info.dart index 90a8656b60..cea883401a 100644 --- a/packages/device_info_plus_platform_interface/lib/model/linux_device_info.dart +++ b/packages/device_info_plus_platform_interface/lib/model/linux_device_info.dart @@ -8,6 +8,7 @@ /// - https://www.freedesktop.org/software/systemd/man/os-release.html /// - https://www.freedesktop.org/software/systemd/man/machine-id.html class LinuxDeviceInfo { + /// Constructs a LinuxDeviceInfo. LinuxDeviceInfo({ this.name, this.version, diff --git a/packages/device_info_plus_platform_interface/lib/model/web_browser_info.dart b/packages/device_info_plus_platform_interface/lib/model/web_browser_info.dart index 38b1897656..fcfc8a13ca 100644 --- a/packages/device_info_plus_platform_interface/lib/model/web_browser_info.dart +++ b/packages/device_info_plus_platform_interface/lib/model/web_browser_info.dart @@ -4,13 +4,28 @@ /// List of supported browsers enum BrowserName { + /// Mozilla Firefox firefox, + + /// Samsumg Internet Browser samsungInternet, + + /// Opera Web Browser opera, + + /// Microsoft Internet Explorer msie, + + /// Microsoft Edge edge, + + /// Google Chrome chrome, + + /// Apple Safari safari, + + /// Unknown web browser unknown, } @@ -36,20 +51,21 @@ class WebBrowserInfo { this.hardwareConcurrency, }); + /// the name of the current browser. BrowserName get browserName { return _parseUserAgentToBrowserName(); } /// the internal "code" name of the current browser. - @Deprecated('Do not rely on this property to return the correct value.') + /// Note: Do not rely on this property to return the correct value. final String appCodeName; /// a DOMString with the official name of the browser. - @Deprecated('Do not rely on this property to return the correct value.') + /// Note: Do not rely on this property to return the correct value. final String appName; /// the version of the browser as a DOMString. - @Deprecated('Do not rely on this property to return the correct value.') + /// Note: Do not rely on this property to return the correct value. final String appVersion; /// the amount of device memory in gigabytes. This value is an approximation given by rounding to the nearest power of 2 and dividing that number by 1024. @@ -62,18 +78,16 @@ class WebBrowserInfo { final List languages; /// the version of the browser as a DOMString. - @Deprecated('Do not rely on this property to return the correct value.') + /// Note: Do not rely on this property to return the correct value. final String platform; /// Always returns 'Gecko', on any browser. - @Deprecated(''' - Do not rely on this property to return the correct value. - This property is kept only for compatibility purpose. - ''') + /// Note: Do not rely on this property to return the correct value. + /// This property is kept only for compatibility purpose. final String product; /// the build number of the current browser - @Deprecated('Do not rely on this property to return the correct value.') + /// Note: Do not rely on this property to return the correct value. final String productSub; /// the build number of the current browser (e.g., "20060909") @@ -83,7 +97,7 @@ class WebBrowserInfo { final String vendor; /// Returns the vendor version number (e.g. "6.1") - @Deprecated('Do not rely on this property to return the correct value.') + /// Note: Do not rely on this property to return the correct value. final String vendorSub; /// the number of logical processor cores available. @@ -113,26 +127,25 @@ class WebBrowserInfo { } BrowserName _parseUserAgentToBrowserName() { - if (userAgent.indexOf("Firefox") > -1) { + if (userAgent.contains("Firefox")) { return BrowserName.firefox; // "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0" - } else if (userAgent.indexOf("SamsungBrowser") > -1) { + } else if (userAgent.contains("SamsungBrowser")) { return BrowserName.samsungInternet; // "Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G955F Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/9.4 Chrome/67.0.3396.87 Mobile Safari/537.36 - } else if (userAgent.indexOf("Opera") > -1 || - userAgent.indexOf("OPR") > -1) { + } else if (userAgent.contains("Opera") || userAgent.contains("OPR")) { return BrowserName.opera; // "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.106" - } else if (userAgent.indexOf("Trident") > -1) { + } else if (userAgent.contains("Trident")) { return BrowserName.msie; // "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Zoom 3.6.0; wbx 1.0.0; rv:11.0) like Gecko" - } else if (userAgent.indexOf("Edge") > -1) { + } else if (userAgent.contains("Edge")) { return BrowserName.edge; // "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299" - } else if (userAgent.indexOf("Chrome") > -1) { + } else if (userAgent.contains("Chrome")) { return BrowserName.chrome; // "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36" - } else if (userAgent.indexOf("Safari") > -1) { + } else if (userAgent.contains("Safari")) { return BrowserName.safari; // "Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1 980x1306" } else { diff --git a/packages/device_info_plus_web/lib/device_info_plus_web.dart b/packages/device_info_plus_web/lib/device_info_plus_web.dart index 7761a98391..77fa2cb306 100644 --- a/packages/device_info_plus_web/lib/device_info_plus_web.dart +++ b/packages/device_info_plus_web/lib/device_info_plus_web.dart @@ -6,6 +6,7 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; /// The web implementation of the BatteryPlusPlatform of the BatteryPlus plugin. class DeviceInfoPlugin extends DeviceInfoPlatform { + /// Constructs a DeviceInfoPlugin. DeviceInfoPlugin(navigator) : _navigator = navigator; final html.Navigator _navigator; diff --git a/packages/package_info_plus_platform_interface/lib/package_info_data.dart b/packages/package_info_plus_platform_interface/lib/package_info_data.dart index 5f383723f7..273c74a44f 100644 --- a/packages/package_info_plus_platform_interface/lib/package_info_data.dart +++ b/packages/package_info_plus_platform_interface/lib/package_info_data.dart @@ -1,3 +1,4 @@ +/// Package info data. class PackageInfoData { /// Constructs an instance with the given values for testing. [PackageInfoData] /// instances constructed this way won't actually reflect any real information diff --git a/packages/sensors_plus/lib/src/sensors.dart b/packages/sensors_plus/lib/src/sensors.dart index 9a5aafae3b..968daa2ad8 100644 --- a/packages/sensors_plus/lib/src/sensors.dart +++ b/packages/sensors_plus/lib/src/sensors.dart @@ -1,5 +1,6 @@ import 'package:sensors_plus_platform_interface/sensors_plus_platform_interface.dart'; +/// The Sensors implementation. class Sensors extends SensorsPlatform { /// Constructs a singleton instance of [Sensors]. /// @@ -12,14 +13,17 @@ class Sensors extends SensorsPlatform { static SensorsPlatform get _platform => SensorsPlatform.instance; + /// A broadcast stream of events from the device accelerometer. Stream get accelerometerEvents { return _platform.accelerometerEvents; } + /// A broadcast stream of events from the device gyroscope. Stream get gyroscopeEvents { return _platform.gyroscopeEvents; } + /// Events from the device accelerometer with gravity removed. Stream get userAccelerometerEvents { return _platform.userAccelerometerEvents; } diff --git a/packages/sensors_plus_platform_interface/lib/sensors_plus_platform_interface.dart b/packages/sensors_plus_platform_interface/lib/sensors_plus_platform_interface.dart index a6bb21c15d..85bd917e32 100644 --- a/packages/sensors_plus_platform_interface/lib/sensors_plus_platform_interface.dart +++ b/packages/sensors_plus_platform_interface/lib/sensors_plus_platform_interface.dart @@ -15,6 +15,7 @@ export 'src/accelerometer_event.dart'; export 'src/gyroscope_event.dart'; export 'src/user_accelerometer_event.dart'; +/// The common platform interface for sensors. abstract class SensorsPlatform extends PlatformInterface { /// Constructs a SensorsPlatform. SensorsPlatform() : super(token: _token); diff --git a/packages/sensors_plus_platform_interface/lib/src/method_channel_sensors.dart b/packages/sensors_plus_platform_interface/lib/src/method_channel_sensors.dart index d73d869caf..c637162744 100644 --- a/packages/sensors_plus_platform_interface/lib/src/method_channel_sensors.dart +++ b/packages/sensors_plus_platform_interface/lib/src/method_channel_sensors.dart @@ -7,6 +7,7 @@ import 'dart:async'; import 'package:flutter/services.dart'; import 'package:sensors_plus_platform_interface/sensors_plus_platform_interface.dart'; +/// A method channel -based implementation of the SensorsPlatform interface. class MethodChannelSensors extends SensorsPlatform { static const EventChannel _accelerometerEventChannel = EventChannel('plugins.flutter.io/sensors/accelerometer'); diff --git a/packages/sensors_plus_web/lib/src/sensors.dart b/packages/sensors_plus_web/lib/src/sensors.dart index 7a20499a09..c713ebc361 100644 --- a/packages/sensors_plus_web/lib/src/sensors.dart +++ b/packages/sensors_plus_web/lib/src/sensors.dart @@ -5,8 +5,8 @@ import 'dart:js'; import 'dart:js_util'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:sensors_plus_platform_interface/sensors_plus_platform_interface.dart'; -import 'package:sensors_plus_web/src/utils.dart'; +/// The sensors plugin. class SensorsPlugin extends SensorsPlatform { /// Factory method that initializes the Battery plugin platform with an instance /// of the plugin for the web. From 3aead9061d47e2b8167841d55e5a72ae4b10730f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 20:11:50 +0200 Subject: [PATCH 07/21] Rename connectivity_web_example -> connectivity_web_test To avoid a failure in build_examples_dart on non-Web platforms. --- packages/connectivity_plus_web/test/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/connectivity_plus_web/test/pubspec.yaml b/packages/connectivity_plus_web/test/pubspec.yaml index b6b7d58ec1..7fa86713ad 100644 --- a/packages/connectivity_plus_web/test/pubspec.yaml +++ b/packages/connectivity_plus_web/test/pubspec.yaml @@ -1,5 +1,5 @@ -name: connectivity_web_example -description: Example web app for the connectivity_plus plugin +name: connectivity_web_test +description: Test web app for the connectivity_plus plugin homepage: https://github.com/fluttercommunity/connectivity_plus/connectivity_web dependencies: From d98130ee236e16279408fc89490e8056397bed02 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 20:37:57 +0200 Subject: [PATCH 08/21] Replace dependency paths as versions --- packages/battery_plus/pubspec.yaml | 6 ++---- packages/battery_plus_web/pubspec.yaml | 3 +-- packages/connectivity_plus/pubspec.yaml | 9 +++------ packages/connectivity_plus_macos/pubspec.yaml | 3 +-- packages/connectivity_plus_web/pubspec.yaml | 3 +-- packages/device_info_plus/pubspec.yaml | 9 +++------ packages/device_info_plus_linux/pubspec.yaml | 3 +-- packages/device_info_plus_web/pubspec.yaml | 3 +-- packages/package_info_plus/pubspec.yaml | 9 +++------ packages/package_info_plus_web/pubspec.yaml | 3 +-- packages/sensors_plus/pubspec.yaml | 6 ++---- packages/sensors_plus_web/pubspec.yaml | 3 +-- 12 files changed, 20 insertions(+), 40 deletions(-) diff --git a/packages/battery_plus/pubspec.yaml b/packages/battery_plus/pubspec.yaml index 9d4f203bf5..81efc96c36 100644 --- a/packages/battery_plus/pubspec.yaml +++ b/packages/battery_plus/pubspec.yaml @@ -18,10 +18,8 @@ dependencies: flutter: sdk: flutter meta: ^1.0.5 - battery_plus_platform_interface: - path: ../battery_plus_platform_interface - battery_plus_web: - path: ../battery_plus_web + battery_plus_platform_interface: ^0.1.0 + battery_plus_web: ^0.1.0 dev_dependencies: async: ^2.0.8 diff --git a/packages/battery_plus_web/pubspec.yaml b/packages/battery_plus_web/pubspec.yaml index 251c752290..f083160620 100644 --- a/packages/battery_plus_web/pubspec.yaml +++ b/packages/battery_plus_web/pubspec.yaml @@ -11,8 +11,7 @@ flutter: fileName: battery_web.dart dependencies: - battery_plus_platform_interface: - path: ../battery_plus_platform_interface + battery_plus_platform_interface: ^0.1.0 flutter_web_plugins: sdk: flutter flutter: diff --git a/packages/connectivity_plus/pubspec.yaml b/packages/connectivity_plus/pubspec.yaml index 48fdf61665..8d1f723a18 100644 --- a/packages/connectivity_plus/pubspec.yaml +++ b/packages/connectivity_plus/pubspec.yaml @@ -20,12 +20,9 @@ dependencies: flutter: sdk: flutter meta: ^1.0.5 - connectivity_plus_platform_interface: - path: ../connectivity_plus_platform_interface - connectivity_plus_macos: - path: ../connectivity_plus_macos - connectivity_plus_web: - path: ../connectivity_plus_web + connectivity_plus_platform_interface: ^0.2.0 + connectivity_plus_macos: ^0.2.0 + connectivity_plus_web: ^0.4.0 dev_dependencies: flutter_test: diff --git a/packages/connectivity_plus_macos/pubspec.yaml b/packages/connectivity_plus_macos/pubspec.yaml index 3f5ee5362a..6c16ee2edb 100644 --- a/packages/connectivity_plus_macos/pubspec.yaml +++ b/packages/connectivity_plus_macos/pubspec.yaml @@ -14,8 +14,7 @@ environment: flutter: ">=1.10.0 <2.0.0" dependencies: - connectivity_plus_platform_interface: - path: ../connectivity_plus_platform_interface + connectivity_plus_platform_interface: ^0.2.0 flutter: sdk: flutter diff --git a/packages/connectivity_plus_web/pubspec.yaml b/packages/connectivity_plus_web/pubspec.yaml index 62a222f76d..e692bf76d2 100644 --- a/packages/connectivity_plus_web/pubspec.yaml +++ b/packages/connectivity_plus_web/pubspec.yaml @@ -11,8 +11,7 @@ flutter: fileName: connectivity_plus_web.dart dependencies: - connectivity_plus_platform_interface: - path: ../connectivity_plus_platform_interface + connectivity_plus_platform_interface: ^0.2.0 flutter_web_plugins: sdk: flutter flutter: diff --git a/packages/device_info_plus/pubspec.yaml b/packages/device_info_plus/pubspec.yaml index 73451d3f6d..22aa277f6f 100644 --- a/packages/device_info_plus/pubspec.yaml +++ b/packages/device_info_plus/pubspec.yaml @@ -20,12 +20,9 @@ flutter: dependencies: flutter: sdk: flutter - device_info_plus_platform_interface: - path: ../device_info_plus_platform_interface - device_info_plus_linux: - path: ../device_info_plus_linux - device_info_plus_web: - path: ../device_info_plus_web + device_info_plus_platform_interface: ^0.2.0 + device_info_plus_linux: ^0.1.0 + device_info_plus_web: ^0.2.0 dev_dependencies: test: ^1.3.0 diff --git a/packages/device_info_plus_linux/pubspec.yaml b/packages/device_info_plus_linux/pubspec.yaml index 86460243e6..092a9f937f 100644 --- a/packages/device_info_plus_linux/pubspec.yaml +++ b/packages/device_info_plus_linux/pubspec.yaml @@ -8,8 +8,7 @@ environment: flutter: ">=1.17.0 <2.0.0" dependencies: - device_info_plus_platform_interface: - path: ../device_info_plus_platform_interface + device_info_plus_platform_interface: ^0.2.0 file: ^6.0.0-nullsafety.1 flutter: sdk: flutter diff --git a/packages/device_info_plus_web/pubspec.yaml b/packages/device_info_plus_web/pubspec.yaml index 61a042bbca..63fc3eaf21 100644 --- a/packages/device_info_plus_web/pubspec.yaml +++ b/packages/device_info_plus_web/pubspec.yaml @@ -11,8 +11,7 @@ flutter: fileName: device_info_plus_web.dart dependencies: - device_info_plus_platform_interface: - path: ../device_info_plus_platform_interface + device_info_plus_platform_interface: ^0.2.0 flutter_web_plugins: sdk: flutter flutter: diff --git a/packages/package_info_plus/pubspec.yaml b/packages/package_info_plus/pubspec.yaml index 87e2bc7a39..3a50ab9639 100644 --- a/packages/package_info_plus/pubspec.yaml +++ b/packages/package_info_plus/pubspec.yaml @@ -19,12 +19,9 @@ flutter: dependencies: flutter: sdk: flutter - package_info_plus_platform_interface: - path: ../package_info_plus_platform_interface - package_info_plus_web: - path: ../package_info_plus_web - package_info_plus_macos: - path: ../package_info_plus_macos + package_info_plus_platform_interface: ^0.1.0 + package_info_plus_web: ^0.1.0 + package_info_plus_macos: ^0.1.0 dev_dependencies: flutter_test: diff --git a/packages/package_info_plus_web/pubspec.yaml b/packages/package_info_plus_web/pubspec.yaml index d616c2e52a..6302a04c92 100644 --- a/packages/package_info_plus_web/pubspec.yaml +++ b/packages/package_info_plus_web/pubspec.yaml @@ -12,8 +12,7 @@ flutter: dependencies: http: any - package_info_plus_platform_interface: - path: ../package_info_plus_platform_interface + package_info_plus_platform_interface: ^0.1.0 platform_detect: ^1.4.0 flutter: sdk: flutter diff --git a/packages/sensors_plus/pubspec.yaml b/packages/sensors_plus/pubspec.yaml index 11bb9e4ee3..b984a2eb92 100644 --- a/packages/sensors_plus/pubspec.yaml +++ b/packages/sensors_plus/pubspec.yaml @@ -17,10 +17,8 @@ flutter: dependencies: flutter: sdk: flutter - sensors_plus_web: - path: ../sensors_plus_web - sensors_plus_platform_interface: - path: ../sensors_plus_platform_interface + sensors_plus_web: ^0.1.0 + sensors_plus_platform_interface: ^0.1.0 dev_dependencies: test: ^1.3.0 diff --git a/packages/sensors_plus_web/pubspec.yaml b/packages/sensors_plus_web/pubspec.yaml index 1ee5687822..c0ad52c0f6 100644 --- a/packages/sensors_plus_web/pubspec.yaml +++ b/packages/sensors_plus_web/pubspec.yaml @@ -17,8 +17,7 @@ flutter: dependencies: flutter: sdk: flutter - sensors_plus_platform_interface: - path: ../sensors_plus_platform_interface + sensors_plus_platform_interface: ^0.1.0 flutter_web_plugins: sdk: flutter From 8ff097c6cb5a3aa1e22602c8e91606c518e1bbfb Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 20:43:21 +0200 Subject: [PATCH 09/21] Rename sensors.dart -> sensors_plus.dart --- packages/sensors_plus/README.md | 2 +- packages/sensors_plus/example/lib/main.dart | 2 +- packages/sensors_plus/example/lib/snake.dart | 2 +- packages/sensors_plus/lib/{sensors.dart => sensors_plus.dart} | 0 packages/sensors_plus/test/sensors_e2e.dart | 2 +- packages/sensors_plus/test/sensors_test.dart | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename packages/sensors_plus/lib/{sensors.dart => sensors_plus.dart} (100%) diff --git a/packages/sensors_plus/README.md b/packages/sensors_plus/README.md index 7240422c96..75e6412e01 100644 --- a/packages/sensors_plus/README.md +++ b/packages/sensors_plus/README.md @@ -28,7 +28,7 @@ Each of these is exposed through a `BroadcastStream`: `accelerometerEvents`, ### Example ``` dart -import 'package:sensors_plus/sensors.dart'; +import 'package:sensors_plus/sensors_plus.dart'; accelerometerEvents.listen((AccelerometerEvent event) { print(event); diff --git a/packages/sensors_plus/example/lib/main.dart b/packages/sensors_plus/example/lib/main.dart index f968cf1360..45574f3d5f 100644 --- a/packages/sensors_plus/example/lib/main.dart +++ b/packages/sensors_plus/example/lib/main.dart @@ -6,7 +6,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:sensors_plus/sensors.dart'; +import 'package:sensors_plus/sensors_plus.dart'; import 'snake.dart'; diff --git a/packages/sensors_plus/example/lib/snake.dart b/packages/sensors_plus/example/lib/snake.dart index 2a3de4457d..f9dbd36120 100644 --- a/packages/sensors_plus/example/lib/snake.dart +++ b/packages/sensors_plus/example/lib/snake.dart @@ -8,7 +8,7 @@ import 'dart:async'; import 'dart:math' as math; import 'package:flutter/material.dart'; -import 'package:sensors_plus/sensors.dart'; +import 'package:sensors_plus/sensors_plus.dart'; class Snake extends StatefulWidget { Snake({this.rows = 20, this.columns = 20, this.cellSize = 10.0}) { diff --git a/packages/sensors_plus/lib/sensors.dart b/packages/sensors_plus/lib/sensors_plus.dart similarity index 100% rename from packages/sensors_plus/lib/sensors.dart rename to packages/sensors_plus/lib/sensors_plus.dart diff --git a/packages/sensors_plus/test/sensors_e2e.dart b/packages/sensors_plus/test/sensors_e2e.dart index e1ba9fe609..975df43806 100644 --- a/packages/sensors_plus/test/sensors_e2e.dart +++ b/packages/sensors_plus/test/sensors_e2e.dart @@ -4,7 +4,7 @@ import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; -import 'package:sensors_plus/sensors.dart'; +import 'package:sensors_plus/sensors_plus.dart'; import 'package:integration_test/integration_test.dart'; void main() { diff --git a/packages/sensors_plus/test/sensors_test.dart b/packages/sensors_plus/test/sensors_test.dart index 009bc3435e..29744a90b8 100644 --- a/packages/sensors_plus/test/sensors_test.dart +++ b/packages/sensors_plus/test/sensors_test.dart @@ -6,7 +6,7 @@ import 'dart:typed_data'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart' show TestWidgetsFlutterBinding; -import 'package:sensors_plus/sensors.dart'; +import 'package:sensors_plus/sensors_plus.dart'; import 'package:test/test.dart'; void main() { From 87c4cf81102d5fca17cdf5a1026a61f95ccf6c51 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 20:44:53 +0200 Subject: [PATCH 10/21] Rename package_info_plus_web.dart --- .../lib/{package_info_web.dart => package_info_plus_web.dart} | 0 packages/package_info_plus_web/pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/package_info_plus_web/lib/{package_info_web.dart => package_info_plus_web.dart} (100%) diff --git a/packages/package_info_plus_web/lib/package_info_web.dart b/packages/package_info_plus_web/lib/package_info_plus_web.dart similarity index 100% rename from packages/package_info_plus_web/lib/package_info_web.dart rename to packages/package_info_plus_web/lib/package_info_plus_web.dart diff --git a/packages/package_info_plus_web/pubspec.yaml b/packages/package_info_plus_web/pubspec.yaml index 6302a04c92..afc5874447 100644 --- a/packages/package_info_plus_web/pubspec.yaml +++ b/packages/package_info_plus_web/pubspec.yaml @@ -8,7 +8,7 @@ flutter: platforms: web: pluginClass: PackageInfoPlugin - fileName: package_info_web.dart + fileName: package_info_plus_web.dart dependencies: http: any From 15a23388805727a4fade6b2af693eb40d7eda0a6 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 20:45:44 +0200 Subject: [PATCH 11/21] Rename package_info_plus_macos.dart --- .../{package_info_macos.dart => package_info_plus_macos.dart} | 0 packages/package_info_plus_macos/pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/package_info_plus_macos/lib/{package_info_macos.dart => package_info_plus_macos.dart} (100%) diff --git a/packages/package_info_plus_macos/lib/package_info_macos.dart b/packages/package_info_plus_macos/lib/package_info_plus_macos.dart similarity index 100% rename from packages/package_info_plus_macos/lib/package_info_macos.dart rename to packages/package_info_plus_macos/lib/package_info_plus_macos.dart diff --git a/packages/package_info_plus_macos/pubspec.yaml b/packages/package_info_plus_macos/pubspec.yaml index 5be0a39f20..0f98df4d54 100644 --- a/packages/package_info_plus_macos/pubspec.yaml +++ b/packages/package_info_plus_macos/pubspec.yaml @@ -8,7 +8,7 @@ flutter: platforms: macos: pluginClass: FLTPackageInfoPlugin - fileName: package_info_macos.dart + fileName: package_info_plus_macos.dart environment: sdk: ">=2.1.0 <3.0.0" From b26939d6da57858878d6a26c8badf388feea7c82 Mon Sep 17 00:00:00 2001 From: Majid Hajian Date: Mon, 12 Oct 2020 20:50:42 +0200 Subject: [PATCH 12/21] fix versions for packages --- packages/device_info_plus_linux/pubspec.yaml | 2 +- packages/package_info_plus_web/pubspec.yaml | 2 +- packages/share_plus_linux/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/device_info_plus_linux/pubspec.yaml b/packages/device_info_plus_linux/pubspec.yaml index 092a9f937f..875c633aad 100644 --- a/packages/device_info_plus_linux/pubspec.yaml +++ b/packages/device_info_plus_linux/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: device_info_plus_platform_interface: ^0.2.0 - file: ^6.0.0-nullsafety.1 + file: ^5.2.1 flutter: sdk: flutter meta: ^1.2.3 diff --git a/packages/package_info_plus_web/pubspec.yaml b/packages/package_info_plus_web/pubspec.yaml index afc5874447..8a6b86d101 100644 --- a/packages/package_info_plus_web/pubspec.yaml +++ b/packages/package_info_plus_web/pubspec.yaml @@ -11,7 +11,7 @@ flutter: fileName: package_info_plus_web.dart dependencies: - http: any + http: ^0.12.0 package_info_plus_platform_interface: ^0.1.0 platform_detect: ^1.4.0 flutter: diff --git a/packages/share_plus_linux/pubspec.yaml b/packages/share_plus_linux/pubspec.yaml index 553d72b5c8..37c89c2d84 100644 --- a/packages/share_plus_linux/pubspec.yaml +++ b/packages/share_plus_linux/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: share_plus_platform_interface: ^1.0.0 - file: ^6.0.0-nullsafety.1 + file: ^5.2.1 flutter: sdk: flutter meta: ^1.2.3 From b71fbc78aee4e09327d9ad8131cc580f4c6f7162 Mon Sep 17 00:00:00 2001 From: Majid Hajian Date: Mon, 12 Oct 2020 20:57:47 +0200 Subject: [PATCH 13/21] remove pubspec yml from test --- .../connectivity_plus_web/test/pubspec.yaml | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 packages/connectivity_plus_web/test/pubspec.yaml diff --git a/packages/connectivity_plus_web/test/pubspec.yaml b/packages/connectivity_plus_web/test/pubspec.yaml deleted file mode 100644 index 7fa86713ad..0000000000 --- a/packages/connectivity_plus_web/test/pubspec.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: connectivity_web_test -description: Test web app for the connectivity_plus plugin -homepage: https://github.com/fluttercommunity/connectivity_plus/connectivity_web - -dependencies: - connectivity_plus_web: - path: ../ - js: ^0.6.1+1 - flutter_web_plugins: - sdk: flutter - flutter: - sdk: flutter - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_driver: - sdk: flutter - integration_test: ^0.9.1 - mockito: ^4.1.1 - -environment: - sdk: ">=2.6.0 <3.0.0" - flutter: ">=1.12.13+hotfix.4" From 00a70f7d1152d916166bf7a25543f7c24cde35d4 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 21:00:17 +0200 Subject: [PATCH 14/21] android_intent_plus: fix platform dependency version --- packages/android_intent_plus/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/android_intent_plus/pubspec.yaml b/packages/android_intent_plus/pubspec.yaml index 0443bd622e..3038829a17 100644 --- a/packages/android_intent_plus/pubspec.yaml +++ b/packages/android_intent_plus/pubspec.yaml @@ -15,7 +15,7 @@ flutter: dependencies: flutter: sdk: flutter - platform: ^3.0.0-nullsafety.2 + platform: ^2.0.0 meta: ^1.0.5 dev_dependencies: test: ^1.3.0 From 97d12c53ad1c24577ab7b52e51b0712e08032d68 Mon Sep 17 00:00:00 2001 From: Majid Hajian Date: Mon, 12 Oct 2020 21:02:21 +0200 Subject: [PATCH 15/21] fix battery plus name --- .../battery_plus_web/lib/battery_web.dart | 73 ------------------- packages/battery_plus_web/pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 packages/battery_plus_web/lib/battery_web.dart diff --git a/packages/battery_plus_web/lib/battery_web.dart b/packages/battery_plus_web/lib/battery_web.dart deleted file mode 100644 index b07830bae1..0000000000 --- a/packages/battery_plus_web/lib/battery_web.dart +++ /dev/null @@ -1,73 +0,0 @@ -import 'dart:async'; -import 'dart:html' as html show window, BatteryManager, Navigator; -import 'dart:js'; -import 'dart:js_util'; -import 'package:battery_plus_platform_interface/battery_plus_platform_interface.dart'; -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; - -/// The web implementation of the BatteryPlatform of the Battery plugin. -class BatteryPlugin extends BatteryPlatform { - /// Constructs a BatteryPlugin. - BatteryPlugin(html.Navigator navigator) : _getBattery = navigator.getBattery; - - /// A check to determine if this version of the plugin can be used. - bool get isSupported => html.window.navigator.getBattery != null; - - final Future Function() _getBattery; - - /// Factory method that initializes the Battery plugin platform with an instance - /// of the plugin for the web. - static void registerWith(Registrar registrar) { - BatteryPlatform.instance = BatteryPlugin(html.window.navigator); - } - - /// Checks the connection status of the device. - @override - Future get batteryLevel async { - if (isSupported) { - // level is a number representing the system's battery charge level scaled to a value between 0.0 and 1.0 - return (await _getBattery() as html.BatteryManager).level * 100; - } - return null; - } - - StreamController _batteryChangeStreamController; - Stream _batteryChange; - - /// Returns a Stream of BatteryState changes. - @override - Stream get onBatteryStateChanged { - if (_batteryChangeStreamController == null && isSupported) { - _batteryChangeStreamController = StreamController(); - - _getBattery().then( - (battery) { - _batteryChangeStreamController - .add(_checkBatteryChargingState(battery.charging)); - setProperty( - battery, - 'onchargingchange', - allowInterop( - (event) { - _batteryChangeStreamController - .add(_checkBatteryChargingState(battery.charging)); - }, - ), - ); - }, - ); - - _batteryChange = - _batteryChangeStreamController.stream.asBroadcastStream(); - } - return _batteryChange; - } - - BatteryState _checkBatteryChargingState(bool charging) { - if (charging) { - return BatteryState.charging; - } else { - return BatteryState.discharging; - } - } -} diff --git a/packages/battery_plus_web/pubspec.yaml b/packages/battery_plus_web/pubspec.yaml index f083160620..d9e981e8c7 100644 --- a/packages/battery_plus_web/pubspec.yaml +++ b/packages/battery_plus_web/pubspec.yaml @@ -8,7 +8,7 @@ flutter: platforms: web: pluginClass: BatteryPlugin - fileName: battery_web.dart + fileName: battery_plus_web.dart dependencies: battery_plus_platform_interface: ^0.1.0 From e44e720b34f137b9fd57cc3417d5560faa21fac1 Mon Sep 17 00:00:00 2001 From: Majid Hajian Date: Mon, 12 Oct 2020 21:05:08 +0200 Subject: [PATCH 16/21] rename batter_plus_web --- .../lib/battery_plus_web.dart | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 packages/battery_plus_web/lib/battery_plus_web.dart diff --git a/packages/battery_plus_web/lib/battery_plus_web.dart b/packages/battery_plus_web/lib/battery_plus_web.dart new file mode 100644 index 0000000000..b07830bae1 --- /dev/null +++ b/packages/battery_plus_web/lib/battery_plus_web.dart @@ -0,0 +1,73 @@ +import 'dart:async'; +import 'dart:html' as html show window, BatteryManager, Navigator; +import 'dart:js'; +import 'dart:js_util'; +import 'package:battery_plus_platform_interface/battery_plus_platform_interface.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + +/// The web implementation of the BatteryPlatform of the Battery plugin. +class BatteryPlugin extends BatteryPlatform { + /// Constructs a BatteryPlugin. + BatteryPlugin(html.Navigator navigator) : _getBattery = navigator.getBattery; + + /// A check to determine if this version of the plugin can be used. + bool get isSupported => html.window.navigator.getBattery != null; + + final Future Function() _getBattery; + + /// Factory method that initializes the Battery plugin platform with an instance + /// of the plugin for the web. + static void registerWith(Registrar registrar) { + BatteryPlatform.instance = BatteryPlugin(html.window.navigator); + } + + /// Checks the connection status of the device. + @override + Future get batteryLevel async { + if (isSupported) { + // level is a number representing the system's battery charge level scaled to a value between 0.0 and 1.0 + return (await _getBattery() as html.BatteryManager).level * 100; + } + return null; + } + + StreamController _batteryChangeStreamController; + Stream _batteryChange; + + /// Returns a Stream of BatteryState changes. + @override + Stream get onBatteryStateChanged { + if (_batteryChangeStreamController == null && isSupported) { + _batteryChangeStreamController = StreamController(); + + _getBattery().then( + (battery) { + _batteryChangeStreamController + .add(_checkBatteryChargingState(battery.charging)); + setProperty( + battery, + 'onchargingchange', + allowInterop( + (event) { + _batteryChangeStreamController + .add(_checkBatteryChargingState(battery.charging)); + }, + ), + ); + }, + ); + + _batteryChange = + _batteryChangeStreamController.stream.asBroadcastStream(); + } + return _batteryChange; + } + + BatteryState _checkBatteryChargingState(bool charging) { + if (charging) { + return BatteryState.charging; + } else { + return BatteryState.discharging; + } + } +} From 4eaa28cff3a12201d49a9b81848ee8ce5f65be7f Mon Sep 17 00:00:00 2001 From: Majid Hajian Date: Mon, 12 Oct 2020 21:10:49 +0200 Subject: [PATCH 17/21] rename android_alarm_manager_plus --- packages/android_alarm_manager_plus/README.md | 2 +- .../example/lib/main.dart | 2 +- .../android_alarm_manager_e2e.dart | 2 +- .../lib/android_alarm_manager.dart | 303 ------------------ .../test/android_alarm_manager_test.dart | 2 +- 5 files changed, 4 insertions(+), 307 deletions(-) delete mode 100644 packages/android_alarm_manager_plus/lib/android_alarm_manager.dart diff --git a/packages/android_alarm_manager_plus/README.md b/packages/android_alarm_manager_plus/README.md index 9e09c10876..b7e040d78e 100644 --- a/packages/android_alarm_manager_plus/README.md +++ b/packages/android_alarm_manager_plus/README.md @@ -38,7 +38,7 @@ Next, within the `` tags, add: Then in Dart code add: ```dart -import 'package:android_alarm_manager/android_alarm_manager.dart'; +import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart'; void printHello() { final DateTime now = DateTime.now(); diff --git a/packages/android_alarm_manager_plus/example/lib/main.dart b/packages/android_alarm_manager_plus/example/lib/main.dart index fb66968103..41d9fc9006 100644 --- a/packages/android_alarm_manager_plus/example/lib/main.dart +++ b/packages/android_alarm_manager_plus/example/lib/main.dart @@ -8,7 +8,7 @@ import 'dart:isolate'; import 'dart:math'; import 'dart:ui'; -import 'package:android_alarm_manager_plus/android_alarm_manager.dart'; +import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter/material.dart'; diff --git a/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e.dart b/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e.dart index 7d57df6c22..862be800be 100644 --- a/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e.dart +++ b/packages/android_alarm_manager_plus/example/test_driver/android_alarm_manager_e2e.dart @@ -4,7 +4,7 @@ import 'dart:async'; import 'dart:io'; -import 'package:android_alarm_manager_plus/android_alarm_manager.dart'; +import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart'; import 'package:e2e/e2e.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/android_alarm_manager_plus/lib/android_alarm_manager.dart b/packages/android_alarm_manager_plus/lib/android_alarm_manager.dart deleted file mode 100644 index d767833020..0000000000 --- a/packages/android_alarm_manager_plus/lib/android_alarm_manager.dart +++ /dev/null @@ -1,303 +0,0 @@ -// Copyright 2017 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 'dart:ui'; - -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -const String _backgroundName = - 'plugins.flutter.io/android_alarm_manager_background'; - -// This is the entrypoint for the background isolate. Since we can only enter -// an isolate once, we setup a MethodChannel to listen for method invocations -// from the native portion of the plugin. This allows for the plugin to perform -// any necessary processing in Dart (e.g., populating a custom object) before -// invoking the provided callback. -void _alarmManagerCallbackDispatcher() { - // Initialize state necessary for MethodChannels. - WidgetsFlutterBinding.ensureInitialized(); - - const _channel = MethodChannel(_backgroundName, JSONMethodCodec()); - // This is where the magic happens and we handle background events from the - // native portion of the plugin. - _channel.setMethodCallHandler((MethodCall call) async { - final dynamic args = call.arguments; - final handle = CallbackHandle.fromRawHandle(args[0]); - - // PluginUtilities.getCallbackFromHandle performs a lookup based on the - // callback handle and returns a tear-off of the original callback. - final closure = PluginUtilities.getCallbackFromHandle(handle); - - if (closure == null) { - print('Fatal: could not find callback'); - exit(-1); - } - - // ignore: inference_failure_on_function_return_type - if (closure is Function()) { - closure(); - // ignore: inference_failure_on_function_return_type - } else if (closure is Function(int)) { - final int id = args[1]; - closure(id); - } - }); - - // Once we've finished initializing, let the native portion of the plugin - // know that it can start scheduling alarms. - _channel.invokeMethod('AlarmService.initialized'); -} - -// A lambda that returns the current instant in the form of a [DateTime]. -typedef _Now = DateTime Function(); -// A lambda that gets the handle for the given [callback]. -typedef _GetCallbackHandle = CallbackHandle Function(Function callback); - -/// A Flutter plugin for registering Dart callbacks with the Android -/// AlarmManager service. -/// -/// See the example/ directory in this package for sample usage. -class AndroidAlarmManager { - static const String _channelName = 'plugins.flutter.io/android_alarm_manager'; - static final MethodChannel _channel = - const MethodChannel(_channelName, JSONMethodCodec()); - - // Function used to get the current time. It's [DateTime.now] by default. - static _Now _now = () => DateTime.now(); - - // Callback used to get the handle for a callback. It's - // [PluginUtilities.getCallbackHandle] by default. - static _GetCallbackHandle _getCallbackHandle = - (Function callback) => PluginUtilities.getCallbackHandle(callback); - - /// This is exposed for the unit tests. It should not be accessed by users of - /// the plugin. - @visibleForTesting - static void setTestOverides( - {_Now now, _GetCallbackHandle getCallbackHandle}) { - _now = (now ?? _now); - _getCallbackHandle = (getCallbackHandle ?? _getCallbackHandle); - } - - /// Starts the [AndroidAlarmManager] service. This must be called before - /// setting any alarms. - /// - /// Returns a [Future] that resolves to `true` on success and `false` on - /// failure. - static Future initialize() async { - final handle = _getCallbackHandle(_alarmManagerCallbackDispatcher); - if (handle == null) { - return false; - } - final r = await _channel.invokeMethod( - 'AlarmService.start', [handle.toRawHandle()]); - return r ?? false; - } - - /// Schedules a one-shot timer to run `callback` after time `delay`. - /// - /// The `callback` will run whether or not the main application is running or - /// in the foreground. It will run in the Isolate owned by the - /// AndroidAlarmManager service. - /// - /// `callback` must be either a top-level function or a static method from a - /// class. - /// - /// `callback` can be `Function()` or `Function(int)` - /// - /// The timer is uniquely identified by `id`. Calling this function again - /// with the same `id` will cancel and replace the existing timer. - /// - /// `id` will passed to `callback` if it is of type `Function(int)` - /// - /// If `alarmClock` is passed as `true`, the timer will be created with - /// Android's `AlarmManagerCompat.setAlarmClock`. - /// - /// If `allowWhileIdle` is passed as `true`, the timer will be created with - /// Android's `AlarmManagerCompat.setExactAndAllowWhileIdle` or - /// `AlarmManagerCompat.setAndAllowWhileIdle`. - /// - /// If `exact` is passed as `true`, the timer will be created with Android's - /// `AlarmManagerCompat.setExact`. When `exact` is `false` (the default), the - /// timer will be created with `AlarmManager.set`. - /// - /// If `wakeup` is passed as `true`, the device will be woken up when the - /// alarm fires. If `wakeup` is false (the default), the device will not be - /// woken up to service the alarm. - /// - /// If `rescheduleOnReboot` is passed as `true`, the alarm will be persisted - /// across reboots. If `rescheduleOnReboot` is false (the default), the alarm - /// will not be rescheduled after a reboot and will not be executed. - /// - /// Returns a [Future] that resolves to `true` on success and `false` on - /// failure. - static Future oneShot( - Duration delay, - int id, - Function callback, { - bool alarmClock = false, - bool allowWhileIdle = false, - bool exact = false, - bool wakeup = false, - bool rescheduleOnReboot = false, - }) => - oneShotAt( - _now().add(delay), - id, - callback, - alarmClock: alarmClock, - allowWhileIdle: allowWhileIdle, - exact: exact, - wakeup: wakeup, - rescheduleOnReboot: rescheduleOnReboot, - ); - - /// Schedules a one-shot timer to run `callback` at `time`. - /// - /// The `callback` will run whether or not the main application is running or - /// in the foreground. It will run in the Isolate owned by the - /// AndroidAlarmManager service. - /// - /// `callback` must be either a top-level function or a static method from a - /// class. - /// - /// `callback` can be `Function()` or `Function(int)` - /// - /// The timer is uniquely identified by `id`. Calling this function again - /// with the same `id` will cancel and replace the existing timer. - /// - /// `id` will passed to `callback` if it is of type `Function(int)` - /// - /// If `alarmClock` is passed as `true`, the timer will be created with - /// Android's `AlarmManagerCompat.setAlarmClock`. - /// - /// If `allowWhileIdle` is passed as `true`, the timer will be created with - /// Android's `AlarmManagerCompat.setExactAndAllowWhileIdle` or - /// `AlarmManagerCompat.setAndAllowWhileIdle`. - /// - /// If `exact` is passed as `true`, the timer will be created with Android's - /// `AlarmManagerCompat.setExact`. When `exact` is `false` (the default), the - /// timer will be created with `AlarmManager.set`. - /// - /// If `wakeup` is passed as `true`, the device will be woken up when the - /// alarm fires. If `wakeup` is false (the default), the device will not be - /// woken up to service the alarm. - /// - /// If `rescheduleOnReboot` is passed as `true`, the alarm will be persisted - /// across reboots. If `rescheduleOnReboot` is false (the default), the alarm - /// will not be rescheduled after a reboot and will not be executed. - /// - /// Returns a [Future] that resolves to `true` on success and `false` on - /// failure. - static Future oneShotAt( - DateTime time, - int id, - Function callback, { - bool alarmClock = false, - bool allowWhileIdle = false, - bool exact = false, - bool wakeup = false, - bool rescheduleOnReboot = false, - }) async { - // ignore: inference_failure_on_function_return_type - assert(callback is Function() || callback is Function(int)); - assert(id.bitLength < 32); - final startMillis = time.millisecondsSinceEpoch; - final handle = _getCallbackHandle(callback); - if (handle == null) { - return false; - } - final r = await _channel.invokeMethod('Alarm.oneShotAt', [ - id, - alarmClock, - allowWhileIdle, - exact, - wakeup, - startMillis, - rescheduleOnReboot, - handle.toRawHandle(), - ]); - return (r == null) ? false : r; - } - - /// Schedules a repeating timer to run `callback` with period `duration`. - /// - /// The `callback` will run whether or not the main application is running or - /// in the foreground. It will run in the Isolate owned by the - /// AndroidAlarmManager service. - /// - /// `callback` must be either a top-level function or a static method from a - /// class. - /// - /// `callback` can be `Function()` or `Function(int)` - /// - /// The repeating timer is uniquely identified by `id`. Calling this function - /// again with the same `id` will cancel and replace the existing timer. - /// - /// `id` will passed to `callback` if it is of type `Function(int)` - /// - /// If `startAt` is passed, the timer will first go off at that time and - /// subsequently run with period `duration`. - /// - /// If `exact` is passed as `true`, the timer will be created with Android's - /// `AlarmManager.setRepeating`. When `exact` is `false` (the default), the - /// timer will be created with `AlarmManager.setInexactRepeating`. - /// - /// If `wakeup` is passed as `true`, the device will be woken up when the - /// alarm fires. If `wakeup` is false (the default), the device will not be - /// woken up to service the alarm. - /// - /// If `rescheduleOnReboot` is passed as `true`, the alarm will be persisted - /// across reboots. If `rescheduleOnReboot` is false (the default), the alarm - /// will not be rescheduled after a reboot and will not be executed. - /// - /// Returns a [Future] that resolves to `true` on success and `false` on - /// failure. - static Future periodic( - Duration duration, - int id, - Function callback, { - DateTime startAt, - bool exact = false, - bool wakeup = false, - bool rescheduleOnReboot = false, - }) async { - // ignore: inference_failure_on_function_return_type - assert(callback is Function() || callback is Function(int)); - assert(id.bitLength < 32); - final now = _now().millisecondsSinceEpoch; - final period = duration.inMilliseconds; - final first = - startAt != null ? startAt.millisecondsSinceEpoch : now + period; - final handle = _getCallbackHandle(callback); - if (handle == null) { - return false; - } - final r = await _channel.invokeMethod('Alarm.periodic', [ - id, - exact, - wakeup, - first, - period, - rescheduleOnReboot, - handle.toRawHandle() - ]); - return (r == null) ? false : r; - } - - /// Cancels a timer. - /// - /// If a timer has been scheduled with `id`, then this function will cancel - /// it. - /// - /// Returns a [Future] that resolves to `true` on success and `false` on - /// failure. - static Future cancel(int id) async { - final r = await _channel.invokeMethod('Alarm.cancel', [id]); - return (r == null) ? false : r; - } -} diff --git a/packages/android_alarm_manager_plus/test/android_alarm_manager_test.dart b/packages/android_alarm_manager_plus/test/android_alarm_manager_test.dart index 60cf8bb7c5..0cfce073e7 100644 --- a/packages/android_alarm_manager_plus/test/android_alarm_manager_test.dart +++ b/packages/android_alarm_manager_plus/test/android_alarm_manager_test.dart @@ -4,7 +4,7 @@ import 'dart:ui'; -import 'package:android_alarm_manager_plus/android_alarm_manager.dart'; +import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; From 636ffdf6e17da897f84a3fbc3e6685e6b6218b56 Mon Sep 17 00:00:00 2001 From: Majid Hajian Date: Mon, 12 Oct 2020 21:10:58 +0200 Subject: [PATCH 18/21] rename android_alarm_manager_plus.dart --- .../lib/android_alarm_manager_plus.dart | 303 ++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 packages/android_alarm_manager_plus/lib/android_alarm_manager_plus.dart diff --git a/packages/android_alarm_manager_plus/lib/android_alarm_manager_plus.dart b/packages/android_alarm_manager_plus/lib/android_alarm_manager_plus.dart new file mode 100644 index 0000000000..d767833020 --- /dev/null +++ b/packages/android_alarm_manager_plus/lib/android_alarm_manager_plus.dart @@ -0,0 +1,303 @@ +// Copyright 2017 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 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +const String _backgroundName = + 'plugins.flutter.io/android_alarm_manager_background'; + +// This is the entrypoint for the background isolate. Since we can only enter +// an isolate once, we setup a MethodChannel to listen for method invocations +// from the native portion of the plugin. This allows for the plugin to perform +// any necessary processing in Dart (e.g., populating a custom object) before +// invoking the provided callback. +void _alarmManagerCallbackDispatcher() { + // Initialize state necessary for MethodChannels. + WidgetsFlutterBinding.ensureInitialized(); + + const _channel = MethodChannel(_backgroundName, JSONMethodCodec()); + // This is where the magic happens and we handle background events from the + // native portion of the plugin. + _channel.setMethodCallHandler((MethodCall call) async { + final dynamic args = call.arguments; + final handle = CallbackHandle.fromRawHandle(args[0]); + + // PluginUtilities.getCallbackFromHandle performs a lookup based on the + // callback handle and returns a tear-off of the original callback. + final closure = PluginUtilities.getCallbackFromHandle(handle); + + if (closure == null) { + print('Fatal: could not find callback'); + exit(-1); + } + + // ignore: inference_failure_on_function_return_type + if (closure is Function()) { + closure(); + // ignore: inference_failure_on_function_return_type + } else if (closure is Function(int)) { + final int id = args[1]; + closure(id); + } + }); + + // Once we've finished initializing, let the native portion of the plugin + // know that it can start scheduling alarms. + _channel.invokeMethod('AlarmService.initialized'); +} + +// A lambda that returns the current instant in the form of a [DateTime]. +typedef _Now = DateTime Function(); +// A lambda that gets the handle for the given [callback]. +typedef _GetCallbackHandle = CallbackHandle Function(Function callback); + +/// A Flutter plugin for registering Dart callbacks with the Android +/// AlarmManager service. +/// +/// See the example/ directory in this package for sample usage. +class AndroidAlarmManager { + static const String _channelName = 'plugins.flutter.io/android_alarm_manager'; + static final MethodChannel _channel = + const MethodChannel(_channelName, JSONMethodCodec()); + + // Function used to get the current time. It's [DateTime.now] by default. + static _Now _now = () => DateTime.now(); + + // Callback used to get the handle for a callback. It's + // [PluginUtilities.getCallbackHandle] by default. + static _GetCallbackHandle _getCallbackHandle = + (Function callback) => PluginUtilities.getCallbackHandle(callback); + + /// This is exposed for the unit tests. It should not be accessed by users of + /// the plugin. + @visibleForTesting + static void setTestOverides( + {_Now now, _GetCallbackHandle getCallbackHandle}) { + _now = (now ?? _now); + _getCallbackHandle = (getCallbackHandle ?? _getCallbackHandle); + } + + /// Starts the [AndroidAlarmManager] service. This must be called before + /// setting any alarms. + /// + /// Returns a [Future] that resolves to `true` on success and `false` on + /// failure. + static Future initialize() async { + final handle = _getCallbackHandle(_alarmManagerCallbackDispatcher); + if (handle == null) { + return false; + } + final r = await _channel.invokeMethod( + 'AlarmService.start', [handle.toRawHandle()]); + return r ?? false; + } + + /// Schedules a one-shot timer to run `callback` after time `delay`. + /// + /// The `callback` will run whether or not the main application is running or + /// in the foreground. It will run in the Isolate owned by the + /// AndroidAlarmManager service. + /// + /// `callback` must be either a top-level function or a static method from a + /// class. + /// + /// `callback` can be `Function()` or `Function(int)` + /// + /// The timer is uniquely identified by `id`. Calling this function again + /// with the same `id` will cancel and replace the existing timer. + /// + /// `id` will passed to `callback` if it is of type `Function(int)` + /// + /// If `alarmClock` is passed as `true`, the timer will be created with + /// Android's `AlarmManagerCompat.setAlarmClock`. + /// + /// If `allowWhileIdle` is passed as `true`, the timer will be created with + /// Android's `AlarmManagerCompat.setExactAndAllowWhileIdle` or + /// `AlarmManagerCompat.setAndAllowWhileIdle`. + /// + /// If `exact` is passed as `true`, the timer will be created with Android's + /// `AlarmManagerCompat.setExact`. When `exact` is `false` (the default), the + /// timer will be created with `AlarmManager.set`. + /// + /// If `wakeup` is passed as `true`, the device will be woken up when the + /// alarm fires. If `wakeup` is false (the default), the device will not be + /// woken up to service the alarm. + /// + /// If `rescheduleOnReboot` is passed as `true`, the alarm will be persisted + /// across reboots. If `rescheduleOnReboot` is false (the default), the alarm + /// will not be rescheduled after a reboot and will not be executed. + /// + /// Returns a [Future] that resolves to `true` on success and `false` on + /// failure. + static Future oneShot( + Duration delay, + int id, + Function callback, { + bool alarmClock = false, + bool allowWhileIdle = false, + bool exact = false, + bool wakeup = false, + bool rescheduleOnReboot = false, + }) => + oneShotAt( + _now().add(delay), + id, + callback, + alarmClock: alarmClock, + allowWhileIdle: allowWhileIdle, + exact: exact, + wakeup: wakeup, + rescheduleOnReboot: rescheduleOnReboot, + ); + + /// Schedules a one-shot timer to run `callback` at `time`. + /// + /// The `callback` will run whether or not the main application is running or + /// in the foreground. It will run in the Isolate owned by the + /// AndroidAlarmManager service. + /// + /// `callback` must be either a top-level function or a static method from a + /// class. + /// + /// `callback` can be `Function()` or `Function(int)` + /// + /// The timer is uniquely identified by `id`. Calling this function again + /// with the same `id` will cancel and replace the existing timer. + /// + /// `id` will passed to `callback` if it is of type `Function(int)` + /// + /// If `alarmClock` is passed as `true`, the timer will be created with + /// Android's `AlarmManagerCompat.setAlarmClock`. + /// + /// If `allowWhileIdle` is passed as `true`, the timer will be created with + /// Android's `AlarmManagerCompat.setExactAndAllowWhileIdle` or + /// `AlarmManagerCompat.setAndAllowWhileIdle`. + /// + /// If `exact` is passed as `true`, the timer will be created with Android's + /// `AlarmManagerCompat.setExact`. When `exact` is `false` (the default), the + /// timer will be created with `AlarmManager.set`. + /// + /// If `wakeup` is passed as `true`, the device will be woken up when the + /// alarm fires. If `wakeup` is false (the default), the device will not be + /// woken up to service the alarm. + /// + /// If `rescheduleOnReboot` is passed as `true`, the alarm will be persisted + /// across reboots. If `rescheduleOnReboot` is false (the default), the alarm + /// will not be rescheduled after a reboot and will not be executed. + /// + /// Returns a [Future] that resolves to `true` on success and `false` on + /// failure. + static Future oneShotAt( + DateTime time, + int id, + Function callback, { + bool alarmClock = false, + bool allowWhileIdle = false, + bool exact = false, + bool wakeup = false, + bool rescheduleOnReboot = false, + }) async { + // ignore: inference_failure_on_function_return_type + assert(callback is Function() || callback is Function(int)); + assert(id.bitLength < 32); + final startMillis = time.millisecondsSinceEpoch; + final handle = _getCallbackHandle(callback); + if (handle == null) { + return false; + } + final r = await _channel.invokeMethod('Alarm.oneShotAt', [ + id, + alarmClock, + allowWhileIdle, + exact, + wakeup, + startMillis, + rescheduleOnReboot, + handle.toRawHandle(), + ]); + return (r == null) ? false : r; + } + + /// Schedules a repeating timer to run `callback` with period `duration`. + /// + /// The `callback` will run whether or not the main application is running or + /// in the foreground. It will run in the Isolate owned by the + /// AndroidAlarmManager service. + /// + /// `callback` must be either a top-level function or a static method from a + /// class. + /// + /// `callback` can be `Function()` or `Function(int)` + /// + /// The repeating timer is uniquely identified by `id`. Calling this function + /// again with the same `id` will cancel and replace the existing timer. + /// + /// `id` will passed to `callback` if it is of type `Function(int)` + /// + /// If `startAt` is passed, the timer will first go off at that time and + /// subsequently run with period `duration`. + /// + /// If `exact` is passed as `true`, the timer will be created with Android's + /// `AlarmManager.setRepeating`. When `exact` is `false` (the default), the + /// timer will be created with `AlarmManager.setInexactRepeating`. + /// + /// If `wakeup` is passed as `true`, the device will be woken up when the + /// alarm fires. If `wakeup` is false (the default), the device will not be + /// woken up to service the alarm. + /// + /// If `rescheduleOnReboot` is passed as `true`, the alarm will be persisted + /// across reboots. If `rescheduleOnReboot` is false (the default), the alarm + /// will not be rescheduled after a reboot and will not be executed. + /// + /// Returns a [Future] that resolves to `true` on success and `false` on + /// failure. + static Future periodic( + Duration duration, + int id, + Function callback, { + DateTime startAt, + bool exact = false, + bool wakeup = false, + bool rescheduleOnReboot = false, + }) async { + // ignore: inference_failure_on_function_return_type + assert(callback is Function() || callback is Function(int)); + assert(id.bitLength < 32); + final now = _now().millisecondsSinceEpoch; + final period = duration.inMilliseconds; + final first = + startAt != null ? startAt.millisecondsSinceEpoch : now + period; + final handle = _getCallbackHandle(callback); + if (handle == null) { + return false; + } + final r = await _channel.invokeMethod('Alarm.periodic', [ + id, + exact, + wakeup, + first, + period, + rescheduleOnReboot, + handle.toRawHandle() + ]); + return (r == null) ? false : r; + } + + /// Cancels a timer. + /// + /// If a timer has been scheduled with `id`, then this function will cancel + /// it. + /// + /// Returns a [Future] that resolves to `true` on success and `false` on + /// failure. + static Future cancel(int id) async { + final r = await _channel.invokeMethod('Alarm.cancel', [id]); + return (r == null) ? false : r; + } +} From 0c6d5c2ef031e85d34e74a131cbf12baf8bcec6d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 21:09:24 +0200 Subject: [PATCH 19/21] Revert "android_intent_plus: fix platform dependency version" This reverts commit 00a70f7d1152d916166bf7a25543f7c24cde35d4. --- packages/android_intent_plus/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/android_intent_plus/pubspec.yaml b/packages/android_intent_plus/pubspec.yaml index 3038829a17..0443bd622e 100644 --- a/packages/android_intent_plus/pubspec.yaml +++ b/packages/android_intent_plus/pubspec.yaml @@ -15,7 +15,7 @@ flutter: dependencies: flutter: sdk: flutter - platform: ^2.0.0 + platform: ^3.0.0-nullsafety.2 meta: ^1.0.5 dev_dependencies: test: ^1.3.0 From c0355b094a3bdaa77db2a4a159c7156f1eabed9f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 21:18:18 +0200 Subject: [PATCH 20/21] Linux: restore file package versions The error was: Because every version of share_plus_linux from path depends on file ^5.2.1 and every version of device_info_plus_linux from path depends on file ^6.0.0-nullsafety.2, --- packages/device_info_plus_linux/pubspec.yaml | 2 +- packages/share_plus_linux/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/device_info_plus_linux/pubspec.yaml b/packages/device_info_plus_linux/pubspec.yaml index 875c633aad..82957cb15a 100644 --- a/packages/device_info_plus_linux/pubspec.yaml +++ b/packages/device_info_plus_linux/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: device_info_plus_platform_interface: ^0.2.0 - file: ^5.2.1 + file: ^6.0.0-nullsafety.2 flutter: sdk: flutter meta: ^1.2.3 diff --git a/packages/share_plus_linux/pubspec.yaml b/packages/share_plus_linux/pubspec.yaml index 37c89c2d84..5f3da780b5 100644 --- a/packages/share_plus_linux/pubspec.yaml +++ b/packages/share_plus_linux/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: share_plus_platform_interface: ^1.0.0 - file: ^5.2.1 + file: ^6.0.0-nullsafety.2 flutter: sdk: flutter meta: ^1.2.3 From 79a088bf87b36b84635a8008613998d4e5704247 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 12 Oct 2020 21:23:21 +0200 Subject: [PATCH 21/21] Fix the versions for real :) --- packages/android_intent_plus/pubspec.yaml | 2 +- packages/device_info_plus_linux/pubspec.yaml | 2 +- packages/share_plus_linux/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/android_intent_plus/pubspec.yaml b/packages/android_intent_plus/pubspec.yaml index 0443bd622e..4215071262 100644 --- a/packages/android_intent_plus/pubspec.yaml +++ b/packages/android_intent_plus/pubspec.yaml @@ -15,7 +15,7 @@ flutter: dependencies: flutter: sdk: flutter - platform: ^3.0.0-nullsafety.2 + platform: '>=2.0.0 <=3.0.0-nullsafety.2' meta: ^1.0.5 dev_dependencies: test: ^1.3.0 diff --git a/packages/device_info_plus_linux/pubspec.yaml b/packages/device_info_plus_linux/pubspec.yaml index 82957cb15a..2cc48d9f1b 100644 --- a/packages/device_info_plus_linux/pubspec.yaml +++ b/packages/device_info_plus_linux/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: device_info_plus_platform_interface: ^0.2.0 - file: ^6.0.0-nullsafety.2 + file: '>=5.2.1 <=6.0.0-nullsafety.2' flutter: sdk: flutter meta: ^1.2.3 diff --git a/packages/share_plus_linux/pubspec.yaml b/packages/share_plus_linux/pubspec.yaml index 5f3da780b5..a40c187ab2 100644 --- a/packages/share_plus_linux/pubspec.yaml +++ b/packages/share_plus_linux/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: share_plus_platform_interface: ^1.0.0 - file: ^6.0.0-nullsafety.2 + file: '>=5.2.1 <=6.0.0-nullsafety.2' flutter: sdk: flutter meta: ^1.2.3