From 8cec8660dcd639b5bc726587531dbe0ace886574 Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Mon, 8 Oct 2018 09:45:56 +0200 Subject: [PATCH] fix CI --- .../example/lib/main.dart | 4 +- packages/android_intent/example/lib/main.dart | 4 +- .../android_intent/lib/android_intent.dart | 16 +-- packages/camera/lib/camera.dart | 46 ++++---- packages/cloud_firestore/lib/src/blob.dart | 3 +- .../cloud_firestore/lib/src/field_value.dart | 4 +- .../cloud_firestore/lib/src/firestore.dart | 38 +++---- .../cloud_firestore/lib/src/geo_point.dart | 3 +- .../lib/src/query_snapshot.dart | 18 +-- .../lib/src/snapshot_metadata.dart | 4 +- .../cloud_firestore/lib/src/transaction.dart | 6 +- .../cloud_functions/lib/cloud_functions.dart | 4 +- packages/device_info/lib/device_info.dart | 4 +- .../firebase_admob/lib/firebase_admob.dart | 56 +++++----- .../example/lib/tabs_page.dart | 4 +- .../lib/firebase_analytics.dart | 10 +- packages/firebase_analytics/lib/observer.dart | 6 +- packages/firebase_auth/lib/firebase_auth.dart | 35 +++--- packages/firebase_database/lib/src/event.dart | 12 +- .../lib/src/firebase_database.dart | 23 ++-- .../lib/firebase_messaging.dart | 8 +- ...mote_config_fetch_throttled_exception.dart | 4 +- .../lib/src/remote_config_settings.dart | 4 +- .../lib/src/remote_config_value.dart | 4 +- .../lib/src/firebase_storage.dart | 14 +-- .../lib/src/storage_reference.dart | 3 +- .../firebase_storage/lib/src/upload_task.dart | 9 +- .../example/lib/place_marker.dart | 4 +- .../google_maps_flutter/lib/src/bitmap.dart | 3 +- .../lib/src/google_map.dart | 2 +- .../google_maps_flutter/lib/src/location.dart | 24 ++-- .../google_maps_flutter/lib/src/marker.dart | 38 +++---- packages/google_maps_flutter/lib/src/ui.dart | 34 +++--- .../google_sign_in/lib/google_sign_in.dart | 64 +++++------ packages/image_picker/example/lib/main.dart | 4 +- packages/local_auth/lib/auth_strings.dart | 28 ++--- .../lib/location_background_plugin.dart | 38 +++---- packages/quick_actions/lib/quick_actions.dart | 12 +- packages/sensors/example/lib/main.dart | 4 +- packages/sensors/example/lib/snake.dart | 26 +++-- packages/sensors/lib/sensors.dart | 12 +- packages/video_player/example/lib/main.dart | 30 ++--- packages/video_player/lib/video_player.dart | 104 +++++++++--------- 43 files changed, 394 insertions(+), 379 deletions(-) diff --git a/packages/android_alarm_manager/example/lib/main.dart b/packages/android_alarm_manager/example/lib/main.dart index 7325ac84920d..8424920ddd4e 100644 --- a/packages/android_alarm_manager/example/lib/main.dart +++ b/packages/android_alarm_manager/example/lib/main.dart @@ -22,14 +22,14 @@ Future ensureFirebaseUser() async { } class HelloMessage { + HelloMessage(this._now, this._msg, this._isolate, this._user, this._token); + final DateTime _now; final String _msg; final int _isolate; final FirebaseUser _user; final String _token; - HelloMessage(this._now, this._msg, this._isolate, this._user, this._token); - @override String toString() { return "[$_now] $_msg " diff --git a/packages/android_intent/example/lib/main.dart b/packages/android_intent/example/lib/main.dart index 90226930785d..07d2e99438ff 100644 --- a/packages/android_intent/example/lib/main.dart +++ b/packages/android_intent/example/lib/main.dart @@ -80,10 +80,10 @@ class MyHomePage extends StatelessWidget { } class ExplicitIntentsWidget extends StatelessWidget { - static const String routeName = "/explicitIntents"; - const ExplicitIntentsWidget(); + static const String routeName = "/explicitIntents"; + void _openGoogleMapsStreetView() { final AndroidIntent intent = AndroidIntent( action: 'action_view', diff --git a/packages/android_intent/lib/android_intent.dart b/packages/android_intent/lib/android_intent.dart index 2be11480a1c7..5409d857713c 100644 --- a/packages/android_intent/lib/android_intent.dart +++ b/packages/android_intent/lib/android_intent.dart @@ -12,14 +12,6 @@ const String kChannelName = 'plugins.flutter.io/android_intent'; /// Flutter plugin for launching arbitrary Android Intents. class AndroidIntent { - final String action; - final String category; - final String data; - final Map arguments; - final String package; - final MethodChannel _channel; - final Platform _platform; - /// Builds an Android intent with the following parameters /// [action] refers to the action parameter of the intent. /// [category] refers to the category of the intent, can be null. @@ -38,6 +30,14 @@ class AndroidIntent { _channel = const MethodChannel(kChannelName), _platform = platform ?? const LocalPlatform(); + final String action; + final String category; + final String data; + final Map arguments; + final String package; + final MethodChannel _channel; + final Platform _platform; + /// Launch the intent. /// /// This works only on Android platforms. Please guard the call so that your diff --git a/packages/camera/lib/camera.dart b/packages/camera/lib/camera.dart index 115245969ed9..baae0f9634cc 100644 --- a/packages/camera/lib/camera.dart +++ b/packages/camera/lib/camera.dart @@ -54,11 +54,11 @@ Future> availableCameras() async { } class CameraDescription { + CameraDescription({this.name, this.lensDirection}); + final String name; final CameraLensDirection lensDirection; - CameraDescription({this.name, this.lensDirection}); - @override bool operator ==(Object o) { return o is CameraDescription && @@ -79,21 +79,21 @@ class CameraDescription { /// This is thrown when the plugin reports an error. class CameraException implements Exception { + CameraException(this.code, this.description); + String code; String description; - CameraException(this.code, this.description); - @override String toString() => '$runtimeType($code, $description)'; } // Build the UI texture view of the video data with textureId. class CameraPreview extends StatelessWidget { - final CameraController controller; - const CameraPreview(this.controller); + final CameraController controller; + @override Widget build(BuildContext context) { return controller.value.isInitialized @@ -104,6 +104,20 @@ class CameraPreview extends StatelessWidget { /// The state of a [CameraController]. class CameraValue { + const CameraValue({ + this.isInitialized, + this.errorDescription, + this.previewSize, + this.isRecordingVideo, + this.isTakingPicture, + }); + + const CameraValue.uninitialized() + : this( + isInitialized: false, + isRecordingVideo: false, + isTakingPicture: false); + /// True after [CameraController.initialize] has completed successfully. final bool isInitialized; @@ -120,20 +134,6 @@ class CameraValue { /// Is `null` until [isInitialized] is `true`. final Size previewSize; - const CameraValue({ - this.isInitialized, - this.errorDescription, - this.previewSize, - this.isRecordingVideo, - this.isTakingPicture, - }); - - const CameraValue.uninitialized() - : this( - isInitialized: false, - isRecordingVideo: false, - isTakingPicture: false); - /// Convenience getter for `previewSize.height / previewSize.width`. /// /// Can only be called when [initialize] is done. @@ -176,6 +176,9 @@ class CameraValue { /// /// To show the camera preview on the screen use a [CameraPreview] widget. class CameraController extends ValueNotifier { + CameraController(this.description, this.resolutionPreset) + : super(const CameraValue.uninitialized()); + final CameraDescription description; final ResolutionPreset resolutionPreset; @@ -184,9 +187,6 @@ class CameraController extends ValueNotifier { StreamSubscription _eventSubscription; Completer _creatingCompleter; - CameraController(this.description, this.resolutionPreset) - : super(const CameraValue.uninitialized()); - /// Initializes the camera on the device. /// /// Throws a [CameraException] if the initialization fails. diff --git a/packages/cloud_firestore/lib/src/blob.dart b/packages/cloud_firestore/lib/src/blob.dart index 186345c7a9e8..665efead5622 100644 --- a/packages/cloud_firestore/lib/src/blob.dart +++ b/packages/cloud_firestore/lib/src/blob.dart @@ -5,9 +5,10 @@ part of cloud_firestore; class Blob { - final Uint8List bytes; const Blob(this.bytes); + final Uint8List bytes; + @override bool operator ==(dynamic other) => other is Blob && diff --git a/packages/cloud_firestore/lib/src/field_value.dart b/packages/cloud_firestore/lib/src/field_value.dart index e1e22eb66b2e..9795ed69edc3 100644 --- a/packages/cloud_firestore/lib/src/field_value.dart +++ b/packages/cloud_firestore/lib/src/field_value.dart @@ -9,11 +9,11 @@ enum FieldValueType { arrayUnion, arrayRemove, delete, serverTimestamp } /// Sentinel values that can be used when writing document fields with set() or /// update(). class FieldValue { + FieldValue._(this.type, this.value); + final FieldValueType type; final dynamic value; - FieldValue._(this.type, this.value); - /// Returns a special value that tells the server to union the given elements /// with any array value that already exists on the server. /// diff --git a/packages/cloud_firestore/lib/src/firestore.dart b/packages/cloud_firestore/lib/src/firestore.dart index 30f3a44414d2..85f15a50b19f 100644 --- a/packages/cloud_firestore/lib/src/firestore.dart +++ b/packages/cloud_firestore/lib/src/firestore.dart @@ -8,25 +8,7 @@ part of cloud_firestore; /// /// You can get an instance by calling [Firestore.instance]. class Firestore { - @visibleForTesting - static const MethodChannel channel = MethodChannel( - 'plugins.flutter.io/cloud_firestore', - StandardMethodCodec(FirestoreMessageCodec()), - ); - - static final Map> _queryObservers = - >{}; - - static final Map> _documentObservers = - >{}; - - static final Map _transactionHandlers = - {}; - static int _transactionHandlerId = 0; - - static bool _initialized = false; - - Firestore({FirebaseApp app}) : this.app = app ?? FirebaseApp.instance { + Firestore({FirebaseApp app}) : app = app ?? FirebaseApp.instance { if (_initialized) return; channel.setMethodCallHandler((MethodCall call) async { if (call.method == 'QuerySnapshot') { @@ -57,6 +39,24 @@ class Firestore { /// If null, the default [FirebaseApp] is used. final FirebaseApp app; + static bool _initialized = false; + + @visibleForTesting + static const MethodChannel channel = MethodChannel( + 'plugins.flutter.io/cloud_firestore', + StandardMethodCodec(FirestoreMessageCodec()), + ); + + static final Map> _queryObservers = + >{}; + + static final Map> _documentObservers = + >{}; + + static final Map _transactionHandlers = + {}; + static int _transactionHandlerId = 0; + @override bool operator ==(dynamic o) => o is Firestore && o.app == app; diff --git a/packages/cloud_firestore/lib/src/geo_point.dart b/packages/cloud_firestore/lib/src/geo_point.dart index 3619da86d2d5..bc91d4d16712 100644 --- a/packages/cloud_firestore/lib/src/geo_point.dart +++ b/packages/cloud_firestore/lib/src/geo_point.dart @@ -5,9 +5,10 @@ part of cloud_firestore; class GeoPoint { + const GeoPoint(this.latitude, this.longitude); + final double latitude; final double longitude; - const GeoPoint(this.latitude, this.longitude); @override bool operator ==(dynamic o) => diff --git a/packages/cloud_firestore/lib/src/query_snapshot.dart b/packages/cloud_firestore/lib/src/query_snapshot.dart index 30e7ea6cfa08..0ec667fbd0ec 100644 --- a/packages/cloud_firestore/lib/src/query_snapshot.dart +++ b/packages/cloud_firestore/lib/src/query_snapshot.dart @@ -6,15 +6,6 @@ part of cloud_firestore; /// A QuerySnapshot contains zero or more DocumentSnapshot objects. class QuerySnapshot { - /// Gets a list of all the documents included in this snapshot - final List documents; - - /// An array of the documents that changed since the last snapshot. If this - /// is the first snapshot, all documents will be in the list as Added changes. - final List documentChanges; - - final Firestore _firestore; - QuerySnapshot._(Map data, this._firestore) : documents = List.generate(data['documents'].length, (int index) { @@ -31,4 +22,13 @@ class QuerySnapshot { _firestore, ); }); + + /// Gets a list of all the documents included in this snapshot + final List documents; + + /// An array of the documents that changed since the last snapshot. If this + /// is the first snapshot, all documents will be in the list as Added changes. + final List documentChanges; + + final Firestore _firestore; } diff --git a/packages/cloud_firestore/lib/src/snapshot_metadata.dart b/packages/cloud_firestore/lib/src/snapshot_metadata.dart index 685c4e9dabb2..39f51f5928e8 100644 --- a/packages/cloud_firestore/lib/src/snapshot_metadata.dart +++ b/packages/cloud_firestore/lib/src/snapshot_metadata.dart @@ -6,6 +6,8 @@ part of cloud_firestore; /// Metadata about a snapshot, describing the state of the snapshot. class SnapshotMetadata { + SnapshotMetadata._(this.hasPendingWrites, this.isFromCache); + /// Whether the snapshot contains the result of local writes that have not yet /// been committed to the backend. /// @@ -23,6 +25,4 @@ class SnapshotMetadata { /// snapshot with `isFomCache` equal to `false` once the client has received /// up-to-date data from the backend. final bool isFromCache; - - SnapshotMetadata._(this.hasPendingWrites, this.isFromCache); } diff --git a/packages/cloud_firestore/lib/src/transaction.dart b/packages/cloud_firestore/lib/src/transaction.dart index 5803557b2798..d9869dea51f7 100644 --- a/packages/cloud_firestore/lib/src/transaction.dart +++ b/packages/cloud_firestore/lib/src/transaction.dart @@ -7,12 +7,12 @@ part of cloud_firestore; typedef Future TransactionHandler(Transaction transaction); class Transaction { - int _transactionId; - Firestore _firestore; - @visibleForTesting Transaction(this._transactionId, this._firestore); + int _transactionId; + Firestore _firestore; + Future get(DocumentReference documentReference) async { final dynamic result = await Firestore.channel .invokeMethod('Transaction#get', { diff --git a/packages/cloud_functions/lib/cloud_functions.dart b/packages/cloud_functions/lib/cloud_functions.dart index 176ce01e70f7..f280a55a13fe 100644 --- a/packages/cloud_functions/lib/cloud_functions.dart +++ b/packages/cloud_functions/lib/cloud_functions.dart @@ -8,11 +8,11 @@ import 'package:flutter/services.dart'; import 'package:meta/meta.dart'; class CloudFunctionsException implements Exception { + CloudFunctionsException._(this.code, this.message, this.details); + final String code; final String message; final dynamic details; - - CloudFunctionsException._(this.code, this.message, this.details); } /// The entry point for accessing a CloudFunctions. diff --git a/packages/device_info/lib/device_info.dart b/packages/device_info/lib/device_info.dart index 3b3d6ae52c60..bc8c63605f0b 100644 --- a/packages/device_info/lib/device_info.dart +++ b/packages/device_info/lib/device_info.dart @@ -8,12 +8,12 @@ import 'package:flutter/services.dart'; /// Provides device and operating system information. class DeviceInfoPlugin { + DeviceInfoPlugin(); + /// Channel used to communicate to native code. static const MethodChannel channel = MethodChannel('plugins.flutter.io/device_info'); - DeviceInfoPlugin(); - /// This information does not change from call to call. Cache it. AndroidDeviceInfo _cachedAndroidDeviceInfo; diff --git a/packages/firebase_admob/lib/firebase_admob.dart b/packages/firebase_admob/lib/firebase_admob.dart index 4f0c278ee145..258840df3b5d 100644 --- a/packages/firebase_admob/lib/firebase_admob.dart +++ b/packages/firebase_admob/lib/firebase_admob.dart @@ -100,10 +100,6 @@ enum AdSizeType { /// and [iOS](https://developers.google.com/admob/ios/banner#banner_sizes) for /// additional details. class AdSize { - final int height; - final int width; - final AdSizeType adSizeType; - // Private constructor. Apps should use the static constants rather than // create their own instances of [AdSize]. const AdSize._({ @@ -112,6 +108,10 @@ class AdSize { @required this.adSizeType, }); + final int height; + final int width; + final AdSizeType adSizeType; + /// The standard banner (320x50) size. static const AdSize banner = AdSize._( width: 320, @@ -167,8 +167,6 @@ class AdSize { /// /// A valid [adUnitId] is required. abstract class MobileAd { - static final Map _allAds = {}; - /// Default constructor, used by subclasses. MobileAd( {@required this.adUnitId, @@ -180,6 +178,8 @@ abstract class MobileAd { _allAds[id] = this; } + static final Map _allAds = {}; + /// Optional targeting info per the native AdMob API. MobileAdTargetingInfo get targetingInfo => _targetingInfo; final MobileAdTargetingInfo _targetingInfo; @@ -238,14 +238,6 @@ abstract class MobileAd { /// A banner ad for the [FirebaseAdMobPlugin]. class BannerAd extends MobileAd { - /// These are AdMob's test ad unit IDs, which always return test ads. You're - /// encouraged to use them for testing in your own apps. - static final String testAdUnitId = Platform.isAndroid - ? 'ca-app-pub-3940256099942544/6300978111' - : 'ca-app-pub-3940256099942544/2934735716'; - - final AdSize size; - /// Create a BannerAd. /// /// A valid [adUnitId] is required. @@ -259,6 +251,14 @@ class BannerAd extends MobileAd { targetingInfo: targetingInfo, listener: listener); + final AdSize size; + + /// These are AdMob's test ad unit IDs, which always return test ads. You're + /// encouraged to use them for testing in your own apps. + static final String testAdUnitId = Platform.isAndroid + ? 'ca-app-pub-3940256099942544/6300978111' + : 'ca-app-pub-3940256099942544/2934735716'; + @override Future load() { return _invokeBooleanMethod("loadBannerAd", { @@ -274,13 +274,6 @@ class BannerAd extends MobileAd { /// A full-screen interstitial ad for the [FirebaseAdMobPlugin]. class InterstitialAd extends MobileAd { - /// A platform-specific AdMob test ad unit ID for interstitials. This ad unit - /// has been specially configured to always return test ads, and developers - /// are encouraged to use it while building and testing their apps. - static final String testAdUnitId = Platform.isAndroid - ? 'ca-app-pub-3940256099942544/1033173712' - : 'ca-app-pub-3940256099942544/4411468910'; - /// Create an Interstitial. /// /// A valid [adUnitId] is required. @@ -293,6 +286,13 @@ class InterstitialAd extends MobileAd { targetingInfo: targetingInfo, listener: listener); + /// A platform-specific AdMob test ad unit ID for interstitials. This ad unit + /// has been specially configured to always return test ads, and developers + /// are encouraged to use it while building and testing their apps. + static final String testAdUnitId = Platform.isAndroid + ? 'ca-app-pub-3940256099942544/1033173712' + : 'ca-app-pub-3940256099942544/4411468910'; + @override Future load() { return _invokeBooleanMethod("loadInterstitialAd", { @@ -361,6 +361,8 @@ typedef void RewardedVideoAdListener(RewardedVideoAdEvent event, /// are so large, it's a good idea to start loading an ad well in advance of /// when it's likely to be needed. class RewardedVideoAd { + RewardedVideoAd._(); + /// A platform-specific AdMob test ad unit ID for rewarded video ads. This ad /// unit has been specially configured to always return test ads, and /// developers are encouraged to use it while building and testing their apps. @@ -370,8 +372,6 @@ class RewardedVideoAd { static final RewardedVideoAd _instance = RewardedVideoAd._(); - RewardedVideoAd._(); - /// The one and only instance of this class. static RewardedVideoAd get instance => _instance; @@ -417,6 +417,11 @@ class RewardedVideoAd { /// * [RewardedVideoAd], a full screen video ad that provides in-app user /// rewards. class FirebaseAdMob { + @visibleForTesting + FirebaseAdMob.private(MethodChannel channel) : _channel = channel { + _channel.setMethodCallHandler(_handleMethod); + } + // A placeholder AdMob App ID for testing. AdMob App IDs and ad unit IDs are // specific to a single operating system, so apps building for both Android and // iOS will need a set for each platform. @@ -424,11 +429,6 @@ class FirebaseAdMob { ? 'ca-app-pub-3940256099942544~3347511713' : 'ca-app-pub-3940256099942544~1458002511'; - @visibleForTesting - FirebaseAdMob.private(MethodChannel channel) : _channel = channel { - _channel.setMethodCallHandler(_handleMethod); - } - static final FirebaseAdMob _instance = FirebaseAdMob.private( const MethodChannel('plugins.flutter.io/firebase_admob'), ); diff --git a/packages/firebase_analytics/example/lib/tabs_page.dart b/packages/firebase_analytics/example/lib/tabs_page.dart index e8942d2cfdc9..9f09998a16e4 100644 --- a/packages/firebase_analytics/example/lib/tabs_page.dart +++ b/packages/firebase_analytics/example/lib/tabs_page.dart @@ -6,12 +6,12 @@ import 'package:flutter/material.dart'; import 'package:firebase_analytics/observer.dart'; class TabsPage extends StatefulWidget { - static const String routeName = '/tab'; - TabsPage(this.observer); final FirebaseAnalyticsObserver observer; + static const String routeName = '/tab'; + @override State createState() => _TabsPageState(observer); } diff --git a/packages/firebase_analytics/lib/firebase_analytics.dart b/packages/firebase_analytics/lib/firebase_analytics.dart index 80115240001a..5d121d6e7ce5 100755 --- a/packages/firebase_analytics/lib/firebase_analytics.dart +++ b/packages/firebase_analytics/lib/firebase_analytics.dart @@ -11,9 +11,6 @@ import 'package:flutter/foundation.dart'; /// Firebase Analytics API. class FirebaseAnalytics { - static final FirebaseAnalytics _instance = FirebaseAnalytics.private( - const MethodChannel('plugins.flutter.io/firebase_analytics')); - /// Provides an instance of this class. factory FirebaseAnalytics() => _instance; @@ -26,6 +23,9 @@ class FirebaseAnalytics { ? FirebaseAnalyticsAndroid.private(platformChannel) : null; + static final FirebaseAnalytics _instance = FirebaseAnalytics.private( + const MethodChannel('plugins.flutter.io/firebase_analytics')); + final MethodChannel _channel; /// Namespace for analytics API available on Android only. @@ -778,11 +778,11 @@ class FirebaseAnalytics { /// Android-specific analytics API. class FirebaseAnalyticsAndroid { - final MethodChannel _channel; - @visibleForTesting const FirebaseAnalyticsAndroid.private(this._channel); + final MethodChannel _channel; + /// Sets whether analytics collection is enabled for this app on this device. /// /// This setting is persisted across app sessions. By default it is enabled. diff --git a/packages/firebase_analytics/lib/observer.dart b/packages/firebase_analytics/lib/observer.dart index 51ab7022da2b..5bcc907b7435 100644 --- a/packages/firebase_analytics/lib/observer.dart +++ b/packages/firebase_analytics/lib/observer.dart @@ -49,14 +49,14 @@ String defaultNameExtractor(RouteSettings settings) => settings.name; /// [PageRouteAware] and subscribing it to [FirebaseAnalyticsObserver]. See the /// [PageRouteObserver] docs for an example. class FirebaseAnalyticsObserver extends RouteObserver> { - final FirebaseAnalytics analytics; - final ScreenNameExtractor nameExtractor; - FirebaseAnalyticsObserver({ @required this.analytics, this.nameExtractor = defaultNameExtractor, }); + final FirebaseAnalytics analytics; + final ScreenNameExtractor nameExtractor; + void _sendScreenView(PageRoute route) { final String screenName = nameExtractor(route.settings); if (screenName != null) { diff --git a/packages/firebase_auth/lib/firebase_auth.dart b/packages/firebase_auth/lib/firebase_auth.dart index 873b8ce3d8f9..5b5328b2302d 100755 --- a/packages/firebase_auth/lib/firebase_auth.dart +++ b/packages/firebase_auth/lib/firebase_auth.dart @@ -10,19 +10,19 @@ import 'package:meta/meta.dart'; /// Represents user data returned from an identity provider. class FirebaseUserMetadata { - final Map _data; - FirebaseUserMetadata._(this._data); + final Map _data; + int get creationTimestamp => _data['creationTimestamp']; int get lastSignInTimestamp => _data['lastSignInTimestamp']; } class UserInfo { - final Map _data; - UserInfo._(this._data); + final Map _data; + /// The provider identifier. String get providerId => _data['providerId']; @@ -66,9 +66,6 @@ class UserUpdateInfo { /// Represents a user. class FirebaseUser extends UserInfo { - final List providerData; - final FirebaseUserMetadata _metadata; - FirebaseUser._(Map data) : providerData = data['providerData'] .map((dynamic item) => UserInfo._(item)) @@ -76,6 +73,9 @@ class FirebaseUser extends UserInfo { _metadata = FirebaseUserMetadata._(data), super._(data); + final List providerData; + final FirebaseUserMetadata _metadata; + // Returns true if the user is anonymous; that is, the user account was // created with signInAnonymously() and has not been linked to another // account. @@ -143,9 +143,10 @@ class FirebaseUser extends UserInfo { } class AuthException implements Exception { + const AuthException(this.code, this.message); + final String code; final String message; - const AuthException(this.code, this.message); } typedef void PhoneVerificationCompleted(FirebaseUser firebaseUser); @@ -154,6 +155,15 @@ typedef void PhoneCodeSent(String verificationId, [int forceResendingToken]); typedef void PhoneCodeAutoRetrievalTimeout(String verificationId); class FirebaseAuth { + FirebaseAuth._() { + channel.setMethodCallHandler(_callHandler); + } + + /// Provides an instance of this class corresponding to the default app. + /// + /// TODO(jackson): Support for non-default apps. + static FirebaseAuth instance = FirebaseAuth._(); + @visibleForTesting static const MethodChannel channel = MethodChannel( 'plugins.flutter.io/firebase_auth', @@ -166,15 +176,6 @@ class FirebaseAuth { final Map> _phoneAuthCallbacks = >{}; - /// Provides an instance of this class corresponding to the default app. - /// - /// TODO(jackson): Support for non-default apps. - static FirebaseAuth instance = FirebaseAuth._(); - - FirebaseAuth._() { - channel.setMethodCallHandler(_callHandler); - } - /// Receive [FirebaseUser] each time the user signIn or signOut Stream get onAuthStateChanged { Future _handle; diff --git a/packages/firebase_database/lib/src/event.dart b/packages/firebase_database/lib/src/event.dart index e935aa98a0a8..59d3c55950ac 100644 --- a/packages/firebase_database/lib/src/event.dart +++ b/packages/firebase_database/lib/src/event.dart @@ -15,19 +15,21 @@ enum _EventType { /// `Event` encapsulates a DataSnapshot and possibly also the key of its /// previous sibling, which can be used to order the snapshots. class Event { - Map _data; Event._(this._data) : snapshot = DataSnapshot._(_data['snapshot']); final DataSnapshot snapshot; + Map _data; + String get previousSiblingKey => _data['previousSiblingKey']; } /// A DataSnapshot contains data from a Firebase Database location. /// Any time you read Firebase data, you receive the data as a DataSnapshot. class DataSnapshot { - final Map _data; DataSnapshot._(this._data); + final Map _data; + /// The key of the location that generated this DataSnapshot. String get key => _data['key']; @@ -36,10 +38,11 @@ class DataSnapshot { } class MutableData { - final Map _data; @visibleForTesting MutableData.private(this._data); + final Map _data; + /// The key of the location that generated this MutableData. String get key => _data['key']; @@ -52,9 +55,10 @@ class MutableData { /// Error that results from a transaction operation at a Firebase Database /// location. class DatabaseError { - Map _data; DatabaseError._(this._data); + Map _data; + /// One of the defined status codes, depending on the error. int get code => _data['code']; diff --git a/packages/firebase_database/lib/src/firebase_database.dart b/packages/firebase_database/lib/src/firebase_database.dart index 5038069ac3ad..9e34796d11a4 100644 --- a/packages/firebase_database/lib/src/firebase_database.dart +++ b/packages/firebase_database/lib/src/firebase_database.dart @@ -8,17 +8,6 @@ part of firebase_database; /// by calling `FirebaseDatabase.instance`. To access a location in the database /// and read or write data, use `reference()`. class FirebaseDatabase { - final MethodChannel _channel = const MethodChannel( - 'plugins.flutter.io/firebase_database', - ); - - static final Map> _observers = - >{}; - - static final Map _transactions = - {}; - - static bool _initialized = false; /// Gets an instance of [FirebaseDatabase]. /// @@ -51,8 +40,20 @@ class FirebaseDatabase { _initialized = true; } + static final Map> _observers = + >{}; + + static final Map _transactions = + {}; + + static bool _initialized = false; + static FirebaseDatabase _instance = FirebaseDatabase(); + final MethodChannel _channel = const MethodChannel( + 'plugins.flutter.io/firebase_database', + ); + /// The [FirebaseApp] instance to which this [FirebaseDatabase] belongs. /// /// If null, the default [FirebaseApp] is used. diff --git a/packages/firebase_messaging/lib/firebase_messaging.dart b/packages/firebase_messaging/lib/firebase_messaging.dart index 2b166e39ea1a..4cacff8b3b3a 100644 --- a/packages/firebase_messaging/lib/firebase_messaging.dart +++ b/packages/firebase_messaging/lib/firebase_messaging.dart @@ -122,10 +122,6 @@ class FirebaseMessaging { } class IosNotificationSettings { - final bool sound; - final bool alert; - final bool badge; - const IosNotificationSettings({ this.sound = true, this.alert = true, @@ -137,6 +133,10 @@ class IosNotificationSettings { alert = settings['alert'], badge = settings['badge']; + final bool sound; + final bool alert; + final bool badge; + @visibleForTesting Map toMap() { return {'sound': sound, 'alert': alert, 'badge': badge}; diff --git a/packages/firebase_remote_config/lib/src/remote_config_fetch_throttled_exception.dart b/packages/firebase_remote_config/lib/src/remote_config_fetch_throttled_exception.dart index b52af2564f26..58e27e249c5f 100644 --- a/packages/firebase_remote_config/lib/src/remote_config_fetch_throttled_exception.dart +++ b/packages/firebase_remote_config/lib/src/remote_config_fetch_throttled_exception.dart @@ -2,12 +2,12 @@ part of firebase_remote_config; /// Exception thrown when the fetch() operation cannot be completed successfully, due to throttling. class FetchThrottledException implements Exception { - DateTime _throttleEnd; - FetchThrottledException._({int endTimeInMills}) { _throttleEnd = DateTime.fromMillisecondsSinceEpoch(endTimeInMills); } + DateTime _throttleEnd; + DateTime get throttleEnd => _throttleEnd; @override diff --git a/packages/firebase_remote_config/lib/src/remote_config_settings.dart b/packages/firebase_remote_config/lib/src/remote_config_settings.dart index bd2770646fa3..eadb645b6ee6 100644 --- a/packages/firebase_remote_config/lib/src/remote_config_settings.dart +++ b/packages/firebase_remote_config/lib/src/remote_config_settings.dart @@ -2,6 +2,8 @@ part of firebase_remote_config; /// RemoteConfigSettings can be used to configure how Remote Config operates. class RemoteConfigSettings { + RemoteConfigSettings({this.debugMode = false}); + /// Enable or disable developer mode for Remote Config. /// /// When set to true developer mode is enabled, when set to false developer @@ -9,6 +11,4 @@ class RemoteConfigSettings { /// relaxed to allow many more fetch calls per hour to the remote server than /// the 5 per hour that is enforced when developer mode is disabled. final bool debugMode; - - RemoteConfigSettings({this.debugMode = false}); } diff --git a/packages/firebase_remote_config/lib/src/remote_config_value.dart b/packages/firebase_remote_config/lib/src/remote_config_value.dart index 8e97e7e98dbc..c7a148f2a72e 100644 --- a/packages/firebase_remote_config/lib/src/remote_config_value.dart +++ b/packages/firebase_remote_config/lib/src/remote_config_value.dart @@ -6,11 +6,11 @@ enum ValueSource { valueStatic, valueDefault, valueRemote } /// RemoteConfigValue encapsulates the value and source of a Remote Config /// parameter. class RemoteConfigValue { + RemoteConfigValue._(this._value, this._source); + List _value; ValueSource _source; - RemoteConfigValue._(this._value, this._source); - /// Indicates at which source this value came from. ValueSource get source => _source == ValueSource.valueDefault ? ValueSource.valueDefault diff --git a/packages/firebase_storage/lib/src/firebase_storage.dart b/packages/firebase_storage/lib/src/firebase_storage.dart index 96472d6c395a..050ebd1c3af8 100644 --- a/packages/firebase_storage/lib/src/firebase_storage.dart +++ b/packages/firebase_storage/lib/src/firebase_storage.dart @@ -7,11 +7,6 @@ part of firebase_storage; /// FirebaseStorage is a service that supports uploading and downloading large /// objects to Google Cloud Storage. class FirebaseStorage { - static const MethodChannel channel = - MethodChannel('plugins.flutter.io/firebase_storage'); - - static bool _initialized = false; - /// Returns the [FirebaseStorage] instance, initialized with a custom /// [FirebaseApp] if [app] is specified and a custom Google Cloud Storage /// bucket if [storageBucket] is specified. Otherwise the instance will be @@ -32,6 +27,11 @@ class FirebaseStorage { _initialized = true; } + static const MethodChannel channel = + MethodChannel('plugins.flutter.io/firebase_storage'); + + static bool _initialized = false; + static FirebaseStorage _instance = FirebaseStorage(); /// The [FirebaseApp] instance to which this [FirebaseStorage] belongs. @@ -111,12 +111,12 @@ class FirebaseStorage { /// TODO: Move into own file and build out progress functionality class StorageFileDownloadTask { + StorageFileDownloadTask._(this._firebaseStorage, this._path, this._file); + final FirebaseStorage _firebaseStorage; final String _path; final File _file; - StorageFileDownloadTask._(this._firebaseStorage, this._path, this._file); - Future _start() async { final int totalByteCount = await FirebaseStorage.channel.invokeMethod( "StorageReference#writeToFile", diff --git a/packages/firebase_storage/lib/src/storage_reference.dart b/packages/firebase_storage/lib/src/storage_reference.dart index cd31160ee2ab..d3e9e2ab7faa 100644 --- a/packages/firebase_storage/lib/src/storage_reference.dart +++ b/packages/firebase_storage/lib/src/storage_reference.dart @@ -5,8 +5,9 @@ part of firebase_storage; class StorageReference { - final FirebaseStorage _firebaseStorage; const StorageReference._(this._pathComponents, this._firebaseStorage); + + final FirebaseStorage _firebaseStorage; final List _pathComponents; /// Returns a new instance of [StorageReference] pointing to a child diff --git a/packages/firebase_storage/lib/src/upload_task.dart b/packages/firebase_storage/lib/src/upload_task.dart index f9f0622a476e..945ed391be48 100644 --- a/packages/firebase_storage/lib/src/upload_task.dart +++ b/packages/firebase_storage/lib/src/upload_task.dart @@ -5,11 +5,12 @@ part of firebase_storage; abstract class StorageUploadTask { + StorageUploadTask._(this._firebaseStorage, this._ref, this._metadata); + final FirebaseStorage _firebaseStorage; final StorageReference _ref; final StorageMetadata _metadata; - StorageUploadTask._(this._firebaseStorage, this._ref, this._metadata); Future _platformStart(); int _handle; @@ -119,11 +120,12 @@ abstract class StorageUploadTask { } class _StorageFileUploadTask extends StorageUploadTask { - final File _file; _StorageFileUploadTask._(this._file, FirebaseStorage firebaseStorage, StorageReference ref, StorageMetadata metadata) : super._(firebaseStorage, ref, metadata); + final File _file; + @override Future _platformStart() { return FirebaseStorage.channel.invokeMethod( @@ -141,11 +143,12 @@ class _StorageFileUploadTask extends StorageUploadTask { } class _StorageDataUploadTask extends StorageUploadTask { - final Uint8List _bytes; _StorageDataUploadTask._(this._bytes, FirebaseStorage firebaseStorage, StorageReference ref, StorageMetadata metadata) : super._(firebaseStorage, ref, metadata); + final Uint8List _bytes; + @override Future _platformStart() { return FirebaseStorage.channel.invokeMethod( diff --git a/packages/google_maps_flutter/example/lib/place_marker.dart b/packages/google_maps_flutter/example/lib/place_marker.dart index 0990309106f9..1fb8a84a6f01 100644 --- a/packages/google_maps_flutter/example/lib/place_marker.dart +++ b/packages/google_maps_flutter/example/lib/place_marker.dart @@ -26,10 +26,10 @@ class PlaceMarkerBody extends StatefulWidget { } class PlaceMarkerBodyState extends State { - static final LatLng center = const LatLng(-33.86711, 151.1947171); - PlaceMarkerBodyState(); + static final LatLng center = const LatLng(-33.86711, 151.1947171); + GoogleMapController controller; int _markerCount = 0; Marker _selectedMarker; diff --git a/packages/google_maps_flutter/lib/src/bitmap.dart b/packages/google_maps_flutter/lib/src/bitmap.dart index 4c4a00e2135f..e7276df25f10 100644 --- a/packages/google_maps_flutter/lib/src/bitmap.dart +++ b/packages/google_maps_flutter/lib/src/bitmap.dart @@ -8,6 +8,8 @@ part of google_maps_flutter; /// image of the marker icon. For a ground overlay, it can be used to set the /// image to place on the surface of the earth. class BitmapDescriptor { + const BitmapDescriptor._(this._json); + static const double hueRed = 0.0; static const double hueOrange = 30.0; static const double hueYellow = 60.0; @@ -19,7 +21,6 @@ class BitmapDescriptor { static const double hueMagenta = 300.0; static const double hueRose = 330.0; - const BitmapDescriptor._(this._json); /// Creates a BitmapDescriptor that refers to the default marker image. static const BitmapDescriptor defaultMarker = diff --git a/packages/google_maps_flutter/lib/src/google_map.dart b/packages/google_maps_flutter/lib/src/google_map.dart index a2f405881a42..03478adecc7b 100644 --- a/packages/google_maps_flutter/lib/src/google_map.dart +++ b/packages/google_maps_flutter/lib/src/google_map.dart @@ -12,7 +12,7 @@ class GoogleMap extends StatefulWidget { GoogleMapOptions options, this.gestureRecognizers = const [], }) : assert(gestureRecognizers != null), - this.options = GoogleMapOptions.defaultOptions.copyWith(options); + options = GoogleMapOptions.defaultOptions.copyWith(options); final MapCreatedCallback onMapCreated; diff --git a/packages/google_maps_flutter/lib/src/location.dart b/packages/google_maps_flutter/lib/src/location.dart index 7a4fca66d4d5..04aba845bc7b 100644 --- a/packages/google_maps_flutter/lib/src/location.dart +++ b/packages/google_maps_flutter/lib/src/location.dart @@ -6,12 +6,6 @@ part of google_maps_flutter; /// A pair of latitude and longitude coordinates, stored as degrees. class LatLng { - /// The latitude in degrees between -90.0 and 90.0, both inclusive. - final double latitude; - - /// The longitude in degrees between -180.0 (inclusive) and 180.0 (exclusive). - final double longitude; - /// Creates a geographical location specified in degrees [latitude] and /// [longitude]. /// @@ -26,6 +20,12 @@ class LatLng { (latitude < -90.0 ? -90.0 : (90.0 < latitude ? 90.0 : latitude)), longitude = (longitude + 180.0) % 360.0 - 180.0; + /// The latitude in degrees between -90.0 and 90.0, both inclusive. + final double latitude; + + /// The longitude in degrees between -180.0 (inclusive) and 180.0 (exclusive). + final double longitude; + dynamic _toJson() { return [latitude, longitude]; } @@ -60,12 +60,6 @@ class LatLng { /// * lng ∈ [-180, `northeast.longitude`] ∪ [`southwest.longitude`, 180[, /// if `northeast.longitude` < `southwest.longitude` class LatLngBounds { - /// The southwest corner of the rectangle. - final LatLng southwest; - - /// The northeast corner of the rectangle. - final LatLng northeast; - /// Creates geographical bounding box with the specified corners. /// /// The latitude of the southwest corner cannot be larger than the @@ -75,6 +69,12 @@ class LatLngBounds { assert(northeast != null), assert(southwest.latitude <= northeast.latitude); + /// The southwest corner of the rectangle. + final LatLng southwest; + + /// The northeast corner of the rectangle. + final LatLng northeast; + dynamic _toJson() { return [southwest._toJson(), northeast._toJson()]; } diff --git a/packages/google_maps_flutter/lib/src/marker.dart b/packages/google_maps_flutter/lib/src/marker.dart index 387c300ca1f4..9ea17c0422ad 100644 --- a/packages/google_maps_flutter/lib/src/marker.dart +++ b/packages/google_maps_flutter/lib/src/marker.dart @@ -58,6 +58,25 @@ class InfoWindowText { /// When used to change configuration, null values will be interpreted as /// "do not change this configuration option". class MarkerOptions { + /// Creates a set of marker configuration options. + /// + /// By default, every non-specified field is null, meaning no desire to change + /// marker defaults or current configuration. + const MarkerOptions({ + this.alpha, + this.anchor, + this.consumeTapEvents, + this.draggable, + this.flat, + this.icon, + this.infoWindowAnchor, + this.infoWindowText, + this.position, + this.rotation, + this.visible, + this.zIndex, + }) : assert(alpha == null || (0.0 <= alpha && alpha <= 1.0)); + /// The opacity of the marker, between 0.0 and 1.0 inclusive. /// /// 0.0 means fully transparent, 1.0 means fully opaque. @@ -112,25 +131,6 @@ class MarkerOptions { /// earlier, and thus appearing to be closer to the surface of the Earth. final double zIndex; - /// Creates a set of marker configuration options. - /// - /// By default, every non-specified field is null, meaning no desire to change - /// marker defaults or current configuration. - const MarkerOptions({ - this.alpha, - this.anchor, - this.consumeTapEvents, - this.draggable, - this.flat, - this.icon, - this.infoWindowAnchor, - this.infoWindowText, - this.position, - this.rotation, - this.visible, - this.zIndex, - }) : assert(alpha == null || (0.0 <= alpha && alpha <= 1.0)); - /// Default marker options. /// /// Specifies a marker that diff --git a/packages/google_maps_flutter/lib/src/ui.dart b/packages/google_maps_flutter/lib/src/ui.dart index ad41a7f324ad..acedb0eb2d88 100644 --- a/packages/google_maps_flutter/lib/src/ui.dart +++ b/packages/google_maps_flutter/lib/src/ui.dart @@ -71,6 +71,23 @@ class MinMaxZoomPreference { /// When used to change configuration, null values will be interpreted as /// "do not change this configuration option". class GoogleMapOptions { + /// Creates a set of map user interface configuration options. + /// + /// By default, every non-specified field is null, meaning no desire to change + /// user interface defaults or current configuration. + GoogleMapOptions({ + this.cameraPosition, + this.compassEnabled, + this.cameraTargetBounds, + this.mapType, + this.minMaxZoomPreference, + this.rotateGesturesEnabled, + this.scrollGesturesEnabled, + this.tiltGesturesEnabled, + this.trackCameraPosition, + this.zoomGesturesEnabled, + }); + /// The desired position of the map camera. /// /// This field is used to indicate initial camera position and to update that @@ -108,23 +125,6 @@ class GoogleMapOptions { /// True if the map view should respond to zoom gestures. final bool zoomGesturesEnabled; - /// Creates a set of map user interface configuration options. - /// - /// By default, every non-specified field is null, meaning no desire to change - /// user interface defaults or current configuration. - GoogleMapOptions({ - this.cameraPosition, - this.compassEnabled, - this.cameraTargetBounds, - this.mapType, - this.minMaxZoomPreference, - this.rotateGesturesEnabled, - this.scrollGesturesEnabled, - this.tiltGesturesEnabled, - this.trackCameraPosition, - this.zoomGesturesEnabled, - }); - /// Default user interface options. /// /// Specifies a map view that diff --git a/packages/google_sign_in/lib/google_sign_in.dart b/packages/google_sign_in/lib/google_sign_in.dart index f24c169677ac..2465890a6c31 100755 --- a/packages/google_sign_in/lib/google_sign_in.dart +++ b/packages/google_sign_in/lib/google_sign_in.dart @@ -16,10 +16,10 @@ export 'widgets.dart'; enum SignInOption { standard, games } class GoogleSignInAuthentication { - final Map _data; - GoogleSignInAuthentication._(this._data); + final Map _data; + /// An OpenID Connect ID token that identifies the user. String get idToken => _data['idToken']; @@ -143,34 +143,6 @@ class GoogleSignInAccount implements GoogleIdentity { /// GoogleSignIn allows you to authenticate Google users. class GoogleSignIn { - // These error codes must match with ones declared on Android and iOS sides. - - /// Error code indicating there is no signed in user and interactive sign in - /// flow is required. - static const String kSignInRequiredError = 'sign_in_required'; - - /// Error code indicating that interactive sign in process was canceled by the - /// user. - static const String kSignInCanceledError = 'sign_in_canceled'; - - /// Error code indicating that attempt to sign in failed. - static const String kSignInFailedError = 'sign_in_failed'; - - /// The [MethodChannel] over which this class communicates. - @visibleForTesting - static const MethodChannel channel = - MethodChannel('plugins.flutter.io/google_sign_in'); - - /// Option to determine the sign in user experience. [SignInOption.games] must - /// not be used on iOS. - final SignInOption signInOption; - - /// The list of [scopes] are OAuth scope codes requested when signing in. - final List scopes; - - /// Domain to restrict sign-in to. - final String hostedDomain; - /// Initializes global sign-in configuration settings. /// /// The [signInOption] determines the user experience. [SigninOption.games] @@ -201,6 +173,34 @@ class GoogleSignIn { return GoogleSignIn(signInOption: SignInOption.games); } + // These error codes must match with ones declared on Android and iOS sides. + + /// Error code indicating there is no signed in user and interactive sign in + /// flow is required. + static const String kSignInRequiredError = 'sign_in_required'; + + /// Error code indicating that interactive sign in process was canceled by the + /// user. + static const String kSignInCanceledError = 'sign_in_canceled'; + + /// Error code indicating that attempt to sign in failed. + static const String kSignInFailedError = 'sign_in_failed'; + + /// The [MethodChannel] over which this class communicates. + @visibleForTesting + static const MethodChannel channel = + MethodChannel('plugins.flutter.io/google_sign_in'); + + /// Option to determine the sign in user experience. [SignInOption.games] must + /// not be used on iOS. + final SignInOption signInOption; + + /// The list of [scopes] are OAuth scope codes requested when signing in. + final List scopes; + + /// Domain to restrict sign-in to. + final String hostedDomain; + StreamController _currentUserController = StreamController.broadcast(); @@ -336,12 +336,12 @@ class GoogleSignIn { } class _MethodCompleter { + _MethodCompleter(this.method); + final String method; final Completer _completer = Completer(); - _MethodCompleter(this.method); - void complete(FutureOr value) { if (value is Future) { value.then(_completer.complete, onError: _completer.completeError); diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index 65fae347d35c..4dceb56e4ff2 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -194,10 +194,10 @@ class _MyHomePageState extends State { } class AspectRatioVideo extends StatefulWidget { - final VideoPlayerController controller; - AspectRatioVideo(this.controller); + final VideoPlayerController controller; + @override AspectRatioVideoState createState() => AspectRatioVideoState(); } diff --git a/packages/local_auth/lib/auth_strings.dart b/packages/local_auth/lib/auth_strings.dart index d4d2fe7193b4..26646bbf41b4 100644 --- a/packages/local_auth/lib/auth_strings.dart +++ b/packages/local_auth/lib/auth_strings.dart @@ -8,15 +8,6 @@ import 'package:intl/intl.dart'; /// /// Provides default values for all messages. class AndroidAuthMessages { - final String fingerprintHint; - final String fingerprintNotRecognized; - final String fingerprintSuccess; - final String cancelButton; - final String signInTitle; - final String fingerprintRequiredTitle; - final String goToSettingsButton; - final String goToSettingsDescription; - const AndroidAuthMessages({ this.fingerprintHint, this.fingerprintNotRecognized, @@ -28,6 +19,15 @@ class AndroidAuthMessages { this.goToSettingsDescription, }); + final String fingerprintHint; + final String fingerprintNotRecognized; + final String fingerprintSuccess; + final String cancelButton; + final String signInTitle; + final String fingerprintRequiredTitle; + final String goToSettingsButton; + final String goToSettingsDescription; + Map get args { return { 'fingerprintHint': fingerprintHint ?? androidFingerprintHint, @@ -49,11 +49,6 @@ class AndroidAuthMessages { /// /// Provides default values for all messages. class IOSAuthMessages { - final String lockOut; - final String goToSettingsButton; - final String goToSettingsDescription; - final String cancelButton; - const IOSAuthMessages({ this.lockOut, this.goToSettingsButton, @@ -61,6 +56,11 @@ class IOSAuthMessages { this.cancelButton, }); + final String lockOut; + final String goToSettingsButton; + final String goToSettingsDescription; + final String cancelButton; + Map get args { return { 'lockOut': lockOut ?? iOSLockOut, diff --git a/packages/location_background/lib/location_background_plugin.dart b/packages/location_background/lib/location_background_plugin.dart index 9b690b27084a..c587a7c0da32 100644 --- a/packages/location_background/lib/location_background_plugin.dart +++ b/packages/location_background/lib/location_background_plugin.dart @@ -24,12 +24,6 @@ enum LocationActivityType { /// A representation of a location update. class Location { - final double _time; - final double latitude; - final double longitude; - final double altitude; - final double speed; - Location( this._time, this.latitude, this.longitude, this.altitude, this.speed); @@ -39,6 +33,12 @@ class Location { location['longitude'], location['altitude'], location['speed']); } + final double _time; + final double latitude; + final double longitude; + final double altitude; + final double speed; + DateTime get time => DateTime.fromMillisecondsSinceEpoch((_time * 1000).round(), isUtc: true); @@ -106,19 +106,6 @@ void _backgroundCallbackDispatcher() { } class LocationBackgroundPlugin { - // The method channel we'll use to communicate with the native portion of our - // plugin. - static const MethodChannel _channel = - MethodChannel('plugins.flutter.io/ios_background_location'); - - static const String _kCancelLocationUpdates = 'cancelLocationUpdates'; - static const String _kMonitorLocationChanges = 'monitorLocationChanges'; - static const String _kStartHeadlessService = 'startHeadlessService'; - - bool pauseLocationUpdatesAutomatically; - bool showsBackgroundLocationIndicator; - LocationActivityType activityType; - LocationBackgroundPlugin( {this.pauseLocationUpdatesAutomatically = false, this.showsBackgroundLocationIndicator = true, @@ -134,6 +121,19 @@ class LocationBackgroundPlugin { .invokeMethod(_kStartHeadlessService, [handle.toRawHandle()]); } + // The method channel we'll use to communicate with the native portion of our + // plugin. + static const MethodChannel _channel = + MethodChannel('plugins.flutter.io/ios_background_location'); + + static const String _kCancelLocationUpdates = 'cancelLocationUpdates'; + static const String _kMonitorLocationChanges = 'monitorLocationChanges'; + static const String _kStartHeadlessService = 'startHeadlessService'; + + bool pauseLocationUpdatesAutomatically; + bool showsBackgroundLocationIndicator; + LocationActivityType activityType; + /// Start getting significant location updates through `callback`. /// /// `callback` is invoked on a background isolate and will not have direct diff --git a/packages/quick_actions/lib/quick_actions.dart b/packages/quick_actions/lib/quick_actions.dart index 0f5952de6a07..4d2acf99874f 100644 --- a/packages/quick_actions/lib/quick_actions.dart +++ b/packages/quick_actions/lib/quick_actions.dart @@ -17,6 +17,12 @@ typedef void QuickActionHandler(String type); /// Home screen quick-action shortcut item. class ShortcutItem { + const ShortcutItem({ + @required this.type, + @required this.localizedTitle, + this.icon, + }); + /// The identifier of this item; should be unique within the app. final String type; @@ -26,12 +32,6 @@ class ShortcutItem { /// Name of native resource (xcassets etc; NOT a Flutter asset) to be /// displayed as the icon for this item. final String icon; - - const ShortcutItem({ - @required this.type, - @required this.localizedTitle, - this.icon, - }); } /// Quick actions plugin. diff --git a/packages/sensors/example/lib/main.dart b/packages/sensors/example/lib/main.dart index 9816aa43a56d..e574a64f5f38 100644 --- a/packages/sensors/example/lib/main.dart +++ b/packages/sensors/example/lib/main.dart @@ -26,10 +26,10 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - final String title; - MyHomePage({Key key, this.title}) : super(key: key); + final String title; + @override _MyHomePageState createState() => _MyHomePageState(); } diff --git a/packages/sensors/example/lib/snake.dart b/packages/sensors/example/lib/snake.dart index 7a359dff52cd..b870791618e9 100644 --- a/packages/sensors/example/lib/snake.dart +++ b/packages/sensors/example/lib/snake.dart @@ -9,25 +9,26 @@ import 'package:flutter/material.dart'; import 'package:sensors/sensors.dart'; class Snake extends StatefulWidget { - final int rows; - final int columns; - final double cellSize; Snake({this.rows = 20, this.columns = 20, this.cellSize = 10.0}) { assert(10 <= rows); assert(10 <= columns); assert(5.0 <= cellSize); } + final int rows; + final int columns; + final double cellSize; + @override State createState() => SnakeState(rows, columns, cellSize); } class SnakeBoardPainter extends CustomPainter { + SnakeBoardPainter(this.state, this.cellSize); + GameState state; double cellSize; - SnakeBoardPainter(this.state, this.cellSize); - @override void paint(Canvas canvas, Size size) { final Paint blackLine = Paint()..color = Colors.black; @@ -53,14 +54,14 @@ class SnakeBoardPainter extends CustomPainter { } class SnakeState extends State { - double cellSize; - GameState state; - AccelerometerEvent acceleration; - SnakeState(int rows, int columns, this.cellSize) { state = GameState(rows, columns); } + double cellSize; + GameState state; + AccelerometerEvent acceleration; + @override Widget build(BuildContext context) { return CustomPaint(painter: SnakeBoardPainter(state, cellSize)); @@ -95,13 +96,14 @@ class SnakeState extends State { } class GameState { - int rows; - int columns; - int snakeLength; GameState(this.rows, this.columns) { snakeLength = math.min(rows, columns) - 5; } + int rows; + int columns; + int snakeLength; + List> body = >[const math.Point(0, 0)]; math.Point direction = const math.Point(1, 0); diff --git a/packages/sensors/lib/sensors.dart b/packages/sensors/lib/sensors.dart index dc4a793b8c18..28254bd64c83 100644 --- a/packages/sensors/lib/sensors.dart +++ b/packages/sensors/lib/sensors.dart @@ -11,6 +11,8 @@ const EventChannel _gyroscopeEventChannel = EventChannel('plugins.flutter.io/sensors/gyroscope'); class AccelerometerEvent { + AccelerometerEvent(this.x, this.y, this.z); + /// Acceleration force along the x axis (including gravity) measured in m/s^2. final double x; @@ -20,13 +22,13 @@ class AccelerometerEvent { /// Acceleration force along the z axis (including gravity) measured in m/s^2. final double z; - AccelerometerEvent(this.x, this.y, this.z); - @override String toString() => '[AccelerometerEvent (x: $x, y: $y, z: $z)]'; } class GyroscopeEvent { + GyroscopeEvent(this.x, this.y, this.z); + /// Rate of rotation around the x axis measured in rad/s. final double x; @@ -36,13 +38,13 @@ class GyroscopeEvent { /// Rate of rotation around the z axis measured in rad/s. final double z; - GyroscopeEvent(this.x, this.y, this.z); - @override String toString() => '[GyroscopeEvent (x: $x, y: $y, z: $z)]'; } class UserAccelerometerEvent { + UserAccelerometerEvent(this.x, this.y, this.z); + /// Acceleration force along the x axis (excluding gravity) measured in m/s^2. final double x; @@ -52,8 +54,6 @@ class UserAccelerometerEvent { /// Acceleration force along the z axis (excluding gravity) measured in m/s^2. final double z; - UserAccelerometerEvent(this.x, this.y, this.z); - @override String toString() => '[UserAccelerometerEvent (x: $x, y: $y, z: $z)]'; } diff --git a/packages/video_player/example/lib/main.dart b/packages/video_player/example/lib/main.dart index b3c9482ec20d..d1cec7fcc68a 100644 --- a/packages/video_player/example/lib/main.dart +++ b/packages/video_player/example/lib/main.dart @@ -15,10 +15,10 @@ import 'package:video_player/video_player.dart'; /// /// Plays (looping) on initialization, and mutes on deactivation. class VideoPlayPause extends StatefulWidget { - final VideoPlayerController controller; - VideoPlayPause(this.controller); + final VideoPlayerController controller; + @override State createState() { return _VideoPlayPauseState(); @@ -26,16 +26,16 @@ class VideoPlayPause extends StatefulWidget { } class _VideoPlayPauseState extends State { - FadeAnimation imageFadeAnim = - FadeAnimation(child: const Icon(Icons.play_arrow, size: 100.0)); - VoidCallback listener; - _VideoPlayPauseState() { listener = () { setState(() {}); }; } + FadeAnimation imageFadeAnim = + FadeAnimation(child: const Icon(Icons.play_arrow, size: 100.0)); + VoidCallback listener; + VideoPlayerController get controller => widget.controller; @override @@ -95,12 +95,12 @@ class _VideoPlayPauseState extends State { } class FadeAnimation extends StatefulWidget { - final Widget child; - final Duration duration; - FadeAnimation( {this.child, this.duration = const Duration(milliseconds: 500)}); + final Widget child; + final Duration duration; + @override _FadeAnimationState createState() => _FadeAnimationState(); } @@ -157,10 +157,10 @@ typedef Widget VideoWidgetBuilder( BuildContext context, VideoPlayerController controller); abstract class PlayerLifeCycle extends StatefulWidget { + PlayerLifeCycle(this.dataSource, this.childBuilder); + final VideoWidgetBuilder childBuilder; final String dataSource; - - PlayerLifeCycle(this.dataSource, this.childBuilder); } /// A widget connecting its life cycle to a [VideoPlayerController] using @@ -270,10 +270,10 @@ Widget buildCard(String title) { } class VideoInListOfCards extends StatelessWidget { - final VideoPlayerController controller; - VideoInListOfCards(this.controller); + final VideoPlayerController controller; + @override Widget build(BuildContext context) { return ListView( @@ -314,10 +314,10 @@ class VideoInListOfCards extends StatelessWidget { } class AspectRatioVideo extends StatefulWidget { - final VideoPlayerController controller; - AspectRatioVideo(this.controller); + final VideoPlayerController controller; + @override AspectRatioVideoState createState() => AspectRatioVideoState(); } diff --git a/packages/video_player/lib/video_player.dart b/packages/video_player/lib/video_player.dart index 1d13fa1c8f20..d95eddd359c1 100644 --- a/packages/video_player/lib/video_player.dart +++ b/packages/video_player/lib/video_player.dart @@ -35,6 +35,23 @@ class DurationRange { /// The duration, current position, buffering state, error state and settings /// of a [VideoPlayerController]. class VideoPlayerValue { + VideoPlayerValue({ + @required this.duration, + this.size, + this.position = const Duration(), + this.buffered = const [], + this.isPlaying = false, + this.isLooping = false, + this.isBuffering = false, + this.volume = 1.0, + this.errorDescription, + }); + + VideoPlayerValue.uninitialized() : this(duration: null); + + VideoPlayerValue.erroneous(String errorDescription) + : this(duration: null, errorDescription: errorDescription); + /// The total duration of the video. /// /// Is null when [initialized] is false. @@ -68,23 +85,6 @@ class VideoPlayerValue { /// Is null when [initialized] is false. final Size size; - VideoPlayerValue({ - @required this.duration, - this.size, - this.position = const Duration(), - this.buffered = const [], - this.isPlaying = false, - this.isLooping = false, - this.isBuffering = false, - this.volume = 1.0, - this.errorDescription, - }); - - VideoPlayerValue.uninitialized() : this(duration: null); - - VideoPlayerValue.erroneous(String errorDescription) - : this(duration: null, errorDescription: errorDescription); - bool get initialized => duration != null; bool get hasError => errorDescription != null; double get aspectRatio => size.width / size.height; @@ -141,20 +141,6 @@ enum DataSourceType { asset, network, file } /// /// After [dispose] all further calls are ignored. class VideoPlayerController extends ValueNotifier { - int _textureId; - final String dataSource; - - /// Describes the type of data source this [VideoPlayerController] - /// is constructed with. - final DataSourceType dataSourceType; - - final String package; - Timer _timer; - bool _isDisposed = false; - Completer _creatingCompleter; - StreamSubscription _eventSubscription; - _VideoAppLifeCycleObserver _lifeCycleObserver; - /// Constructs a [VideoPlayerController] playing a video from an asset. /// /// The name of the asset is given by the [dataSource] argument and must not be @@ -184,6 +170,20 @@ class VideoPlayerController extends ValueNotifier { package = null, super(VideoPlayerValue(duration: null)); + int _textureId; + final String dataSource; + + /// Describes the type of data source this [VideoPlayerController] + /// is constructed with. + final DataSourceType dataSourceType; + + final String package; + Timer _timer; + bool _isDisposed = false; + Completer _creatingCompleter; + StreamSubscription _eventSubscription; + _VideoAppLifeCycleObserver _lifeCycleObserver; + @visibleForTesting int get textureId => _textureId; @@ -394,11 +394,11 @@ class VideoPlayerController extends ValueNotifier { } class _VideoAppLifeCycleObserver extends Object with WidgetsBindingObserver { + _VideoAppLifeCycleObserver(this._controller); + bool _wasPlayingBeforePause = false; final VideoPlayerController _controller; - _VideoAppLifeCycleObserver(this._controller); - void initialize() { WidgetsBinding.instance.addObserver(this); } @@ -426,18 +426,15 @@ class _VideoAppLifeCycleObserver extends Object with WidgetsBindingObserver { /// Displays the video controlled by [controller]. class VideoPlayer extends StatefulWidget { - final VideoPlayerController controller; - VideoPlayer(this.controller); + final VideoPlayerController controller; + @override _VideoPlayerState createState() => _VideoPlayerState(); } class _VideoPlayerState extends State { - VoidCallback _listener; - int _textureId; - _VideoPlayerState() { _listener = () { final int newTextureId = widget.controller.textureId; @@ -449,6 +446,9 @@ class _VideoPlayerState extends State { }; } + VoidCallback _listener; + int _textureId; + @override void initState() { super.initState(); @@ -479,26 +479,26 @@ class _VideoPlayerState extends State { } class VideoProgressColors { - final Color playedColor; - final Color bufferedColor; - final Color backgroundColor; - VideoProgressColors({ this.playedColor = const Color.fromRGBO(255, 0, 0, 0.7), this.bufferedColor = const Color.fromRGBO(50, 50, 200, 0.2), this.backgroundColor = const Color.fromRGBO(200, 200, 200, 0.5), }); + + final Color playedColor; + final Color bufferedColor; + final Color backgroundColor; } class _VideoScrubber extends StatefulWidget { - final Widget child; - final VideoPlayerController controller; - _VideoScrubber({ @required this.child, @required this.controller, }); + final Widget child; + final VideoPlayerController controller; + @override _VideoScrubberState createState() => _VideoScrubberState(); } @@ -559,11 +559,6 @@ class _VideoScrubberState extends State<_VideoScrubber> { /// [padding] allows to specify some extra padding around the progress indicator /// that will also detect the gestures. class VideoProgressIndicator extends StatefulWidget { - final VideoPlayerController controller; - final VideoProgressColors colors; - final bool allowScrubbing; - final EdgeInsets padding; - VideoProgressIndicator( this.controller, { VideoProgressColors colors, @@ -571,13 +566,16 @@ class VideoProgressIndicator extends StatefulWidget { this.padding = const EdgeInsets.only(top: 5.0), }) : colors = colors ?? VideoProgressColors(); + final VideoPlayerController controller; + final VideoProgressColors colors; + final bool allowScrubbing; + final EdgeInsets padding; + @override _VideoProgressIndicatorState createState() => _VideoProgressIndicatorState(); } class _VideoProgressIndicatorState extends State { - VoidCallback listener; - _VideoProgressIndicatorState() { listener = () { if (!mounted) { @@ -587,6 +585,8 @@ class _VideoProgressIndicatorState extends State { }; } + VoidCallback listener; + VideoPlayerController get controller => widget.controller; VideoProgressColors get colors => widget.colors;