From 0ac91541eb31f5dea883c62d6ea1136cc266c795 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Tue, 29 Dec 2020 14:57:20 -0500 Subject: [PATCH 1/6] migrate to null safety --- packages/sensors/CHANGELOG.md | 4 +++ packages/sensors/example/lib/main.dart | 20 +++++------ packages/sensors/example/lib/snake.dart | 23 ++++++------ packages/sensors/example/pubspec.yaml | 4 +-- .../test_driver/test/integration_test.dart | 2 ++ .../integration_test/sensors_test.dart | 2 ++ packages/sensors/lib/sensors.dart | 36 +++++++------------ packages/sensors/pubspec.yaml | 10 +++--- packages/sensors/test/sensors_test.dart | 10 +++--- 9 files changed, 55 insertions(+), 56 deletions(-) diff --git a/packages/sensors/CHANGELOG.md b/packages/sensors/CHANGELOG.md index 8970f1e76e5d..682d377a6b84 100644 --- a/packages/sensors/CHANGELOG.md +++ b/packages/sensors/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.0-nullsafety + +* Migrate to null safety. + ## 0.4.2+8 * Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) diff --git a/packages/sensors/example/lib/main.dart b/packages/sensors/example/lib/main.dart index 575e0493742f..d6f01380c534 100644 --- a/packages/sensors/example/lib/main.dart +++ b/packages/sensors/example/lib/main.dart @@ -28,7 +28,7 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @@ -41,21 +41,21 @@ class _MyHomePageState extends State { static const int _snakeColumns = 20; static const double _snakeCellSize = 10.0; - List _accelerometerValues; - List _userAccelerometerValues; - List _gyroscopeValues; + List? _accelerometerValues; + List? _userAccelerometerValues; + List? _gyroscopeValues; List> _streamSubscriptions = >[]; @override Widget build(BuildContext context) { - final List accelerometer = - _accelerometerValues?.map((double v) => v.toStringAsFixed(1))?.toList(); - final List gyroscope = - _gyroscopeValues?.map((double v) => v.toStringAsFixed(1))?.toList(); - final List userAccelerometer = _userAccelerometerValues + final List? accelerometer = + _accelerometerValues?.map((double v) => v.toStringAsFixed(1)).toList(); + final List? gyroscope = + _gyroscopeValues?.map((double v) => v.toStringAsFixed(1)).toList(); + final List? userAccelerometer = _userAccelerometerValues ?.map((double v) => v.toStringAsFixed(1)) - ?.toList(); + .toList(); return Scaffold( appBar: AppBar( diff --git a/packages/sensors/example/lib/snake.dart b/packages/sensors/example/lib/snake.dart index d6b2f9b48a23..fe91f0a88bab 100644 --- a/packages/sensors/example/lib/snake.dart +++ b/packages/sensors/example/lib/snake.dart @@ -61,10 +61,10 @@ class SnakeState extends State { } double cellSize; - GameState state; - AccelerometerEvent acceleration; - StreamSubscription _streamSubscription; - Timer _timer; + late final GameState state; + AccelerometerEvent? acceleration; + late final StreamSubscription _streamSubscription; + late final Timer _timer; @override Widget build(BuildContext context) { @@ -96,13 +96,14 @@ class SnakeState extends State { } void _step() { - final math.Point newDirection = acceleration == null + final math.Point? newDirection = acceleration == null ? null - : acceleration.x.abs() < 1.0 && acceleration.y.abs() < 1.0 + : acceleration!.x.abs() < 1.0 && acceleration!.y.abs() < 1.0 ? null - : (acceleration.x.abs() < acceleration.y.abs()) - ? math.Point(0, acceleration.y.sign.toInt()) - : math.Point(-acceleration.x.sign.toInt(), 0); + : (acceleration!.x.abs() < acceleration!.y.abs()) + ? math.Point(0, acceleration!.y.sign.toInt()) + : math.Point(-acceleration!.x.sign.toInt(), 0); + state.step(newDirection); } } @@ -114,12 +115,12 @@ class GameState { int rows; int columns; - int snakeLength; + late int snakeLength; List> body = >[const math.Point(0, 0)]; math.Point direction = const math.Point(1, 0); - void step(math.Point newDirection) { + void step(math.Point? newDirection) { math.Point next = body.last + direction; next = math.Point(next.x % columns, next.y % rows); diff --git a/packages/sensors/example/pubspec.yaml b/packages/sensors/example/pubspec.yaml index eb46c611a43a..6aa76a1da2eb 100644 --- a/packages/sensors/example/pubspec.yaml +++ b/packages/sensors/example/pubspec.yaml @@ -12,12 +12,12 @@ dev_dependencies: sdk: flutter integration_test: path: ../../integration_test - pedantic: ^1.8.0 + pedantic: ^1.10.0-nullsafety.3 flutter: uses-material-design: true environment: - sdk: ">=2.0.0-dev.28.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" flutter: ">=1.9.1+hotfix.2 <2.0.0" diff --git a/packages/sensors/example/test_driver/test/integration_test.dart b/packages/sensors/example/test_driver/test/integration_test.dart index 7a2c21338786..a8a56aa90f6a 100644 --- a/packages/sensors/example/test_driver/test/integration_test.dart +++ b/packages/sensors/example/test_driver/test/integration_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart = 2.9 + import 'dart:async'; import 'dart:convert'; import 'dart:io'; diff --git a/packages/sensors/integration_test/sensors_test.dart b/packages/sensors/integration_test/sensors_test.dart index ea1db0375f38..348bda00d86e 100644 --- a/packages/sensors/integration_test/sensors_test.dart +++ b/packages/sensors/integration_test/sensors_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart = 2.9 + import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; import 'package:sensors/sensors.dart'; diff --git a/packages/sensors/lib/sensors.dart b/packages/sensors/lib/sensors.dart index 0b6f1b5a6067..8c7436c51882 100644 --- a/packages/sensors/lib/sensors.dart +++ b/packages/sensors/lib/sensors.dart @@ -121,38 +121,28 @@ GyroscopeEvent _listToGyroscopeEvent(List list) { return GyroscopeEvent(list[0], list[1], list[2]); } -Stream _accelerometerEvents; -Stream _gyroscopeEvents; -Stream _userAccelerometerEvents; +Stream? _accelerometerEvents; +Stream? _gyroscopeEvents; +Stream? _userAccelerometerEvents; /// A broadcast stream of events from the device accelerometer. Stream get accelerometerEvents { - if (_accelerometerEvents == null) { - _accelerometerEvents = _accelerometerEventChannel - .receiveBroadcastStream() - .map( - (dynamic event) => _listToAccelerometerEvent(event.cast())); - } - return _accelerometerEvents; + return _accelerometerEvents ??= _accelerometerEventChannel + .receiveBroadcastStream() + .map((dynamic event) => _listToAccelerometerEvent(event.cast())); } /// A broadcast stream of events from the device gyroscope. Stream get gyroscopeEvents { - if (_gyroscopeEvents == null) { - _gyroscopeEvents = _gyroscopeEventChannel - .receiveBroadcastStream() - .map((dynamic event) => _listToGyroscopeEvent(event.cast())); - } - return _gyroscopeEvents; + return _gyroscopeEvents ??= _gyroscopeEvents = _gyroscopeEventChannel + .receiveBroadcastStream() + .map((dynamic event) => _listToGyroscopeEvent(event.cast())); } /// Events from the device accelerometer with gravity removed. Stream get userAccelerometerEvents { - if (_userAccelerometerEvents == null) { - _userAccelerometerEvents = _userAccelerometerEventChannel - .receiveBroadcastStream() - .map((dynamic event) => - _listToUserAccelerometerEvent(event.cast())); - } - return _userAccelerometerEvents; + return _userAccelerometerEvents ??= _userAccelerometerEvents = + _userAccelerometerEventChannel.receiveBroadcastStream().map( + (dynamic event) => + _listToUserAccelerometerEvent(event.cast())); } diff --git a/packages/sensors/pubspec.yaml b/packages/sensors/pubspec.yaml index 35feb4b1ed56..8b8590492967 100644 --- a/packages/sensors/pubspec.yaml +++ b/packages/sensors/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/sensors # 0.4.y+z is compatible with 1.0.0, if you land a breaking change bump # the version to 2.0.0. # See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0 -version: 0.4.2+8 +version: 0.5.0-nullsafety flutter: plugin: @@ -21,14 +21,14 @@ dependencies: sdk: flutter dev_dependencies: - test: ^1.3.0 + test: 1.16.0-nullsafety.13 flutter_test: sdk: flutter integration_test: path: ../integration_test - mockito: ^4.1.1 - pedantic: ^1.8.0 + mockito: ^5.0.0-nullsafety.0 + pedantic: ^1.10.0-nullsafety.3 environment: - sdk: ">=2.1.0<3.0.0" + sdk: ">=2.12.0-0 <3.0.0" flutter: ">=1.12.13+hotfix.5" diff --git a/packages/sensors/test/sensors_test.dart b/packages/sensors/test/sensors_test.dart index 832a2f8524b7..93e0959befed 100644 --- a/packages/sensors/test/sensors_test.dart +++ b/packages/sensors/test/sensors_test.dart @@ -52,16 +52,16 @@ void main() { void _initializeFakeSensorChannel(String channelName, List sensorData) { const StandardMethodCodec standardMethod = StandardMethodCodec(); - void _emitEvent(ByteData event) { - ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( + void _emitEvent(ByteData? event) { + ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( channelName, event, - (ByteData reply) {}, + (ByteData? reply) {}, ); } - 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)); From c84958474392cff0c05146da91cf5fb63dd63e4d Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Thu, 14 Jan 2021 14:46:32 -0500 Subject: [PATCH 2/6] use min dependencies and fix some changes --- packages/sensors/example/pubspec.yaml | 2 +- packages/sensors/lib/sensors.dart | 42 ++++++++++++++++++++------- packages/sensors/pubspec.yaml | 4 +-- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/packages/sensors/example/pubspec.yaml b/packages/sensors/example/pubspec.yaml index 6aa76a1da2eb..675c41a29c03 100644 --- a/packages/sensors/example/pubspec.yaml +++ b/packages/sensors/example/pubspec.yaml @@ -12,7 +12,7 @@ dev_dependencies: sdk: flutter integration_test: path: ../../integration_test - pedantic: ^1.10.0-nullsafety.3 + pedantic: ^1.10.0-nullsafety flutter: uses-material-design: true diff --git a/packages/sensors/lib/sensors.dart b/packages/sensors/lib/sensors.dart index 8c7436c51882..8f69255bcec7 100644 --- a/packages/sensors/lib/sensors.dart +++ b/packages/sensors/lib/sensors.dart @@ -127,22 +127,44 @@ Stream? _userAccelerometerEvents; /// A broadcast stream of events from the device accelerometer. Stream get accelerometerEvents { - return _accelerometerEvents ??= _accelerometerEventChannel - .receiveBroadcastStream() - .map((dynamic event) => _listToAccelerometerEvent(event.cast())); + Stream? accelerometerEvents = _accelerometerEvents; + if (accelerometerEvents == null) { + accelerometerEvents = + _accelerometerEventChannel.receiveBroadcastStream().map( + (dynamic event) => + _listToAccelerometerEvent(event.cast()), + ); + _accelerometerEvents = accelerometerEvents; + } + + return accelerometerEvents; } /// A broadcast stream of events from the device gyroscope. Stream get gyroscopeEvents { - return _gyroscopeEvents ??= _gyroscopeEvents = _gyroscopeEventChannel - .receiveBroadcastStream() - .map((dynamic event) => _listToGyroscopeEvent(event.cast())); + Stream? gyroscopeEvents = _gyroscopeEvents; + if (gyroscopeEvents == null) { + gyroscopeEvents = _gyroscopeEventChannel.receiveBroadcastStream().map( + (dynamic event) => _listToGyroscopeEvent(event.cast()), + ); + _gyroscopeEvents = gyroscopeEvents; + } + + return gyroscopeEvents; } /// Events from the device accelerometer with gravity removed. Stream get userAccelerometerEvents { - return _userAccelerometerEvents ??= _userAccelerometerEvents = - _userAccelerometerEventChannel.receiveBroadcastStream().map( - (dynamic event) => - _listToUserAccelerometerEvent(event.cast())); + Stream? userAccelerometerEvents = + _userAccelerometerEvents; + if (userAccelerometerEvents == null) { + userAccelerometerEvents = + _userAccelerometerEventChannel.receiveBroadcastStream().map( + (dynamic event) => + _listToUserAccelerometerEvent(event.cast()), + ); + _userAccelerometerEvents = userAccelerometerEvents; + } + + return userAccelerometerEvents; } diff --git a/packages/sensors/pubspec.yaml b/packages/sensors/pubspec.yaml index 8b8590492967..e9b0392bae8d 100644 --- a/packages/sensors/pubspec.yaml +++ b/packages/sensors/pubspec.yaml @@ -21,13 +21,13 @@ dependencies: sdk: flutter dev_dependencies: - test: 1.16.0-nullsafety.13 + test: ^1.16.0-nullsafety flutter_test: sdk: flutter integration_test: path: ../integration_test mockito: ^5.0.0-nullsafety.0 - pedantic: ^1.10.0-nullsafety.3 + pedantic: ^1.10.0-nullsafety environment: sdk: ">=2.12.0-0 <3.0.0" From 948709e4698d8b1aa875fa5956e46f03d3b8c5c6 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Thu, 14 Jan 2021 14:50:51 -0500 Subject: [PATCH 3/6] add to null safety list --- .../example/ios/Flutter/Debug.xcconfig | 1 + .../example/ios/Flutter/Release.xcconfig | 1 + .../example/ios/Flutter/Debug.xcconfig | 1 + .../example/ios/Flutter/Release.xcconfig | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 32 +------------------ script/nnbd_plugins.sh | 1 + 6 files changed, 6 insertions(+), 31 deletions(-) diff --git a/packages/quick_actions/example/ios/Flutter/Debug.xcconfig b/packages/quick_actions/example/ios/Flutter/Debug.xcconfig index e8efba114687..b2f5fae9c254 100644 --- a/packages/quick_actions/example/ios/Flutter/Debug.xcconfig +++ b/packages/quick_actions/example/ios/Flutter/Debug.xcconfig @@ -1,2 +1,3 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/quick_actions/example/ios/Flutter/Release.xcconfig b/packages/quick_actions/example/ios/Flutter/Release.xcconfig index 399e9340e6f6..88c29144c836 100644 --- a/packages/quick_actions/example/ios/Flutter/Release.xcconfig +++ b/packages/quick_actions/example/ios/Flutter/Release.xcconfig @@ -1,2 +1,3 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/packages/sensors/example/ios/Flutter/Debug.xcconfig b/packages/sensors/example/ios/Flutter/Debug.xcconfig index e8efba114687..b2f5fae9c254 100644 --- a/packages/sensors/example/ios/Flutter/Debug.xcconfig +++ b/packages/sensors/example/ios/Flutter/Debug.xcconfig @@ -1,2 +1,3 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/sensors/example/ios/Flutter/Release.xcconfig b/packages/sensors/example/ios/Flutter/Release.xcconfig index 399e9340e6f6..88c29144c836 100644 --- a/packages/sensors/example/ios/Flutter/Release.xcconfig +++ b/packages/sensors/example/ios/Flutter/Release.xcconfig @@ -1,2 +1,3 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/packages/sensors/example/ios/Runner.xcodeproj/project.pbxproj b/packages/sensors/example/ios/Runner.xcodeproj/project.pbxproj index 8bde68c84719..625279fb3235 100644 --- a/packages/sensors/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/sensors/example/ios/Runner.xcodeproj/project.pbxproj @@ -9,10 +9,6 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; @@ -28,8 +24,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -40,7 +34,6 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 518BFCF6A33590E963FE1FA9 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 65D7779632A59CFED1723B85 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -48,7 +41,6 @@ 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; @@ -63,8 +55,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, A5B646543530B300A487D9B1 /* libPods-Runner.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -84,9 +74,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( - 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEBA1CF902C7004384FC /* Flutter.framework */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 9740EEB31CF90195004384FC /* Generated.xcconfig */, @@ -159,7 +147,6 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 2EB2E4FB0B576731DB30F0C4 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -217,21 +204,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 2EB2E4FB0B576731DB30F0C4 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -244,7 +216,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; 7B77DB2BA78582CC43C8E79F /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; @@ -315,7 +287,6 @@ /* Begin XCBuildConfiguration section */ 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -372,7 +343,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; diff --git a/script/nnbd_plugins.sh b/script/nnbd_plugins.sh index 0cab28abe2ab..9fcdfcf82158 100644 --- a/script/nnbd_plugins.sh +++ b/script/nnbd_plugins.sh @@ -14,6 +14,7 @@ readonly NNBD_PLUGINS_LIST=( "local_auth" "path_provider" "plugin_platform_interface" + "sensors" "share" "url_launcher" "video_player" From 5cec27c71317e3801a2a5855840c016a3297b481 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Thu, 14 Jan 2021 14:54:01 -0500 Subject: [PATCH 4/6] undo xcconfig change --- packages/quick_actions/example/ios/Flutter/Debug.xcconfig | 1 - packages/quick_actions/example/ios/Flutter/Release.xcconfig | 1 - packages/sensors/example/ios/Flutter/Debug.xcconfig | 1 - packages/sensors/example/ios/Flutter/Release.xcconfig | 1 - 4 files changed, 4 deletions(-) diff --git a/packages/quick_actions/example/ios/Flutter/Debug.xcconfig b/packages/quick_actions/example/ios/Flutter/Debug.xcconfig index b2f5fae9c254..e8efba114687 100644 --- a/packages/quick_actions/example/ios/Flutter/Debug.xcconfig +++ b/packages/quick_actions/example/ios/Flutter/Debug.xcconfig @@ -1,3 +1,2 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/quick_actions/example/ios/Flutter/Release.xcconfig b/packages/quick_actions/example/ios/Flutter/Release.xcconfig index 88c29144c836..399e9340e6f6 100644 --- a/packages/quick_actions/example/ios/Flutter/Release.xcconfig +++ b/packages/quick_actions/example/ios/Flutter/Release.xcconfig @@ -1,3 +1,2 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/packages/sensors/example/ios/Flutter/Debug.xcconfig b/packages/sensors/example/ios/Flutter/Debug.xcconfig index b2f5fae9c254..e8efba114687 100644 --- a/packages/sensors/example/ios/Flutter/Debug.xcconfig +++ b/packages/sensors/example/ios/Flutter/Debug.xcconfig @@ -1,3 +1,2 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/sensors/example/ios/Flutter/Release.xcconfig b/packages/sensors/example/ios/Flutter/Release.xcconfig index 88c29144c836..399e9340e6f6 100644 --- a/packages/sensors/example/ios/Flutter/Release.xcconfig +++ b/packages/sensors/example/ios/Flutter/Release.xcconfig @@ -1,3 +1,2 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" From 3240c50856879bb9536dbdf907ea4b4b34901aff Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Thu, 14 Jan 2021 15:06:42 -0500 Subject: [PATCH 5/6] revert back to master --- .../ios/Runner.xcodeproj/project.pbxproj | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/sensors/example/ios/Runner.xcodeproj/project.pbxproj b/packages/sensors/example/ios/Runner.xcodeproj/project.pbxproj index 625279fb3235..8bde68c84719 100644 --- a/packages/sensors/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/sensors/example/ios/Runner.xcodeproj/project.pbxproj @@ -9,6 +9,10 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; @@ -24,6 +28,8 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -34,6 +40,7 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 518BFCF6A33590E963FE1FA9 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 65D7779632A59CFED1723B85 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -41,6 +48,7 @@ 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; @@ -55,6 +63,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, A5B646543530B300A487D9B1 /* libPods-Runner.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -74,7 +84,9 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( + 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEBA1CF902C7004384FC /* Flutter.framework */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 9740EEB31CF90195004384FC /* Generated.xcconfig */, @@ -147,6 +159,7 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 2EB2E4FB0B576731DB30F0C4 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -204,6 +217,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 2EB2E4FB0B576731DB30F0C4 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -216,7 +244,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; }; 7B77DB2BA78582CC43C8E79F /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; @@ -287,6 +315,7 @@ /* Begin XCBuildConfiguration section */ 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -343,6 +372,7 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; From 8229e855d659fbb3a809420df9b9abff1dbbfa9f Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Mon, 8 Feb 2021 11:52:05 -0800 Subject: [PATCH 6/6] Revert example directory --- packages/sensors/example/lib/main.dart | 20 ++++++++-------- packages/sensors/example/lib/snake.dart | 23 +++++++++---------- packages/sensors/example/pubspec.yaml | 4 ++-- .../test_driver/test/integration_test.dart | 2 -- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/packages/sensors/example/lib/main.dart b/packages/sensors/example/lib/main.dart index d6f01380c534..575e0493742f 100644 --- a/packages/sensors/example/lib/main.dart +++ b/packages/sensors/example/lib/main.dart @@ -28,7 +28,7 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - MyHomePage({Key? key, required this.title}) : super(key: key); + MyHomePage({Key key, this.title}) : super(key: key); final String title; @@ -41,21 +41,21 @@ class _MyHomePageState extends State { static const int _snakeColumns = 20; static const double _snakeCellSize = 10.0; - List? _accelerometerValues; - List? _userAccelerometerValues; - List? _gyroscopeValues; + List _accelerometerValues; + List _userAccelerometerValues; + List _gyroscopeValues; List> _streamSubscriptions = >[]; @override Widget build(BuildContext context) { - final List? accelerometer = - _accelerometerValues?.map((double v) => v.toStringAsFixed(1)).toList(); - final List? gyroscope = - _gyroscopeValues?.map((double v) => v.toStringAsFixed(1)).toList(); - final List? userAccelerometer = _userAccelerometerValues + final List accelerometer = + _accelerometerValues?.map((double v) => v.toStringAsFixed(1))?.toList(); + final List gyroscope = + _gyroscopeValues?.map((double v) => v.toStringAsFixed(1))?.toList(); + final List userAccelerometer = _userAccelerometerValues ?.map((double v) => v.toStringAsFixed(1)) - .toList(); + ?.toList(); return Scaffold( appBar: AppBar( diff --git a/packages/sensors/example/lib/snake.dart b/packages/sensors/example/lib/snake.dart index fe91f0a88bab..d6b2f9b48a23 100644 --- a/packages/sensors/example/lib/snake.dart +++ b/packages/sensors/example/lib/snake.dart @@ -61,10 +61,10 @@ class SnakeState extends State { } double cellSize; - late final GameState state; - AccelerometerEvent? acceleration; - late final StreamSubscription _streamSubscription; - late final Timer _timer; + GameState state; + AccelerometerEvent acceleration; + StreamSubscription _streamSubscription; + Timer _timer; @override Widget build(BuildContext context) { @@ -96,14 +96,13 @@ class SnakeState extends State { } void _step() { - final math.Point? newDirection = acceleration == null + final math.Point newDirection = acceleration == null ? null - : acceleration!.x.abs() < 1.0 && acceleration!.y.abs() < 1.0 + : acceleration.x.abs() < 1.0 && acceleration.y.abs() < 1.0 ? null - : (acceleration!.x.abs() < acceleration!.y.abs()) - ? math.Point(0, acceleration!.y.sign.toInt()) - : math.Point(-acceleration!.x.sign.toInt(), 0); - + : (acceleration.x.abs() < acceleration.y.abs()) + ? math.Point(0, acceleration.y.sign.toInt()) + : math.Point(-acceleration.x.sign.toInt(), 0); state.step(newDirection); } } @@ -115,12 +114,12 @@ class GameState { int rows; int columns; - late int snakeLength; + int snakeLength; List> body = >[const math.Point(0, 0)]; math.Point direction = const math.Point(1, 0); - void step(math.Point? newDirection) { + void step(math.Point newDirection) { math.Point next = body.last + direction; next = math.Point(next.x % columns, next.y % rows); diff --git a/packages/sensors/example/pubspec.yaml b/packages/sensors/example/pubspec.yaml index 675c41a29c03..eb46c611a43a 100644 --- a/packages/sensors/example/pubspec.yaml +++ b/packages/sensors/example/pubspec.yaml @@ -12,12 +12,12 @@ dev_dependencies: sdk: flutter integration_test: path: ../../integration_test - pedantic: ^1.10.0-nullsafety + pedantic: ^1.8.0 flutter: uses-material-design: true environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.0.0-dev.28.0 <3.0.0" flutter: ">=1.9.1+hotfix.2 <2.0.0" diff --git a/packages/sensors/example/test_driver/test/integration_test.dart b/packages/sensors/example/test_driver/test/integration_test.dart index a8a56aa90f6a..7a2c21338786 100644 --- a/packages/sensors/example/test_driver/test/integration_test.dart +++ b/packages/sensors/example/test_driver/test/integration_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'dart:convert'; import 'dart:io';