Skip to content

Commit

Permalink
refactor: upgrade project to remove warnings from Flutter 3.7 (#10344)
Browse files Browse the repository at this point in the history
* refactor: remove deprecated lints in Flutter 3.7

* refactor: remove deprecated lints in Flutter 3.7

* refactor: remove deprecated lints in Flutter 3.7

* refactor: remove deprecated lints in Flutter 3.7

* refactor: remove deprecated lints in Flutter 3.7

* refactor: remove deprecated lints in Flutter 3.7

* refactor: remove deprecated lints in Flutter 3.7

* refactor: remove deprecated lints in Flutter 3.7
  • Loading branch information
Lyokone authored Jan 31, 2023
1 parent b703055 commit e0087c8
Show file tree
Hide file tree
Showing 57 changed files with 197 additions and 305 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ jobs:
restore-keys: firebase-emulators-v1
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
# TODO(Lyokone): upgrade to stable when https://github.com/flutter/flutter/issues/118469 is closed
flutter-version: '3.3.10'
cache: true
- uses: bluefireteam/melos-action@v2
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/firebase_firestore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ jobs:
java-version: '11'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
# TODO(Lyokone): upgrade to stable when https://github.com/flutter/flutter/issues/118469 is closed
flutter-version: '3.3.10'
cache: true
- uses: bluefireteam/melos-action@v1
with:
Expand Down
4 changes: 0 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ linter:
# and `@required Widget child` last.
always_put_required_named_parameters_first: false

# `as` is not that bad (especially with the upcoming non-nullable types).
# Explicit exceptions is better than implicit exceptions.
avoid_as: false

# This project doesn't use Flutter-style todos
flutter_style_todos: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,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.

import 'package:firebase_core/firebase_core.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
Expand Down Expand Up @@ -100,7 +100,7 @@ class _FilmListState extends State<FilmList> {
builder: (context, _) {
return Text(
'Latest Snapshot: ${DateTime.now()}',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
);
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class _FilmListState extends State<FilmList> {
builder: (context, _) {
return Text(
'Latest Snapshot: ${DateTime.now()}',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
);
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXAggregateTarget section */
Expand Down Expand Up @@ -260,6 +260,7 @@
/* Begin PBXShellScriptBuildPhase section */
3399D490228B24CF009A79C7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -425,7 +426,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -505,7 +506,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -552,7 +553,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export 'src/field_path.dart';
export 'src/geo_point.dart';
export 'src/get_options.dart';
export 'src/load_bundle_task_state.dart';
export 'src/load_bundle_task_state.dart';
export 'src/persistence_settings.dart';
export 'src/platform_interface/platform_interface_aggregate_query.dart';
export 'src/platform_interface/platform_interface_aggregate_query_snapshot.dart';
Expand All @@ -28,8 +27,6 @@ export 'src/platform_interface/platform_interface_field_value_factory.dart';
export 'src/platform_interface/platform_interface_firestore.dart';
export 'src/platform_interface/platform_interface_index_definitions.dart';
export 'src/platform_interface/platform_interface_load_bundle_task.dart';
export 'src/platform_interface/platform_interface_load_bundle_task.dart';
export 'src/platform_interface/platform_interface_load_bundle_task_snapshot.dart';
export 'src/platform_interface/platform_interface_load_bundle_task_snapshot.dart';
export 'src/platform_interface/platform_interface_query.dart';
export 'src/platform_interface/platform_interface_query_snapshot.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ class Settings {
);

@override
String toString() => 'Settings(${asMap.toString()})';
String toString() => 'Settings($asMap)';
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ abstract class FirestoreJsImpl {

// TODO how?
// external void settings(Settings settings);

}

@JS('WriteBatch')
Expand Down Expand Up @@ -480,7 +479,8 @@ abstract class TimestampJsImpl {
@anonymous
@JS()
abstract class FirestoreError {
external String /*|'cancelled'|'unknown'|'invalid-argument'|'deadline-exceeded'|'not-found'|'already-exists'|'permission-denied'|'resource-exhausted'|'failed-precondition'|'aborted'|'out-of-range'|'unimplemented'|'internal'|'unavailable'|'data-loss'|'unauthenticated'*/ get code;
external String /*|'cancelled'|'unknown'|'invalid-argument'|'deadline-exceeded'|'not-found'|'already-exists'|'permission-denied'|'resource-exhausted'|'failed-precondition'|'aborted'|'out-of-range'|'unimplemented'|'internal'|'unavailable'|'data-loss'|'unauthenticated'*/
get code;

external set code(
/*|'cancelled'|'unknown'|'invalid-argument'|'deadline-exceeded'|'not-found'|'already-exists'|'permission-denied'|'resource-exhausted'|'failed-precondition'|'aborted'|'out-of-range'|'unimplemented'|'internal'|'unavailable'|'data-loss'|'unauthenticated'*/
Expand Down
4 changes: 0 additions & 4 deletions packages/cloud_firestore_odm/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ linter:
# and `@required Widget child` last.
always_put_required_named_parameters_first: false

# `as` is not that bad (especially with the upcoming non-nullable types).
# Explicit exceptions is better than implicit exceptions.
avoid_as: false

# This project doesn't use Flutter-style todos
flutter_style_todos: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AdvancedJson {
@JsonKey(name: 'LAST_NAME')
final String? lastName;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
final String? ignored;

Map<String, Object?> toJson() => _$AdvancedJsonToJson(this);
Expand Down Expand Up @@ -77,7 +77,7 @@ class _PrivateAdvancedJson {
@JsonKey(name: 'LAST_NAME')
final String? lastName;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
final String? ignored;

Map<String, Object?> toJson() => _$PrivateAdvancedJsonToJson(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class _FilmListState extends State<FilmList> {
builder: (context, _) {
return Text(
'Latest Snapshot: ${DateTime.now()}',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
);
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cloud_firestore_odm/cloud_firestore_odm.dart';
import 'package:json_annotation/json_annotation.dart';

import 'model.dart';

part 'simple.g.dart';
Expand All @@ -20,10 +21,10 @@ class IgnoredGetter {

int get count => 42;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
int get count2 => 42;

@JsonKey(ignore: false)
@JsonKey(includeFromJson: true, includeToJson: true)
int get count3 => 42;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class CollectionData with Names {
final type = CollectionData.modelTypeOfAnnotation(annotation);

final hasJsonSerializable =
jsonSerializableChecker.hasAnnotationOf(type.element2!);
jsonSerializableChecker.hasAnnotationOf(type.element!);

if (type.isDynamic) {
throw InvalidGenerationSourceError(
Expand All @@ -126,15 +126,15 @@ class CollectionData with Names {
);
}

final collectionTargetElement = type.element2;
final collectionTargetElement = type.element;
if (collectionTargetElement is! ClassElement) {
throw InvalidGenerationSourceError(
'The annotation @Collection can only receive classes as generic argument. ',
element: annotatedElement,
);
}

final hasFreezed = freezedChecker.hasAnnotationOf(type.element2!);
final hasFreezed = freezedChecker.hasAnnotationOf(type.element!);
final redirectedFreezedConstructors =
collectionTargetElement.constructors.where(
(element) {
Expand Down Expand Up @@ -272,7 +272,7 @@ represents the content of the collection must be in the same file.
if (hasFreezed) {
key =
// two $ because both Freezed and json_serializable add one
'_\$\$${redirectedFreezedConstructors.single.redirectedConstructor!.enclosingElement3.name}FieldMap[$key]!';
'_\$\$${redirectedFreezedConstructors.single.redirectedConstructor!.enclosingElement.name}FieldMap[$key]!';
} else if (hasJsonSerializable) {
key = '_\$${collectionTargetElement.name.public}FieldMap[$key]!';
}
Expand Down Expand Up @@ -411,7 +411,7 @@ extension on ClassElement {
for (final supertype in allSupertypes) {
if (supertype.isDartCoreObject) continue;

for (final field in supertype.element2.fields) {
for (final field in supertype.element.fields) {
if (field.getter != null && !field.getter!.isSynthetic) {
continue;
}
Expand All @@ -431,10 +431,10 @@ extension on String {

extension on DartType {
bool get isJsonDocumentReference {
return element2?.librarySource?.uri.scheme == 'package' &&
return element?.librarySource?.uri.scheme == 'package' &&
const {'cloud_firestore'}
.contains(element2?.librarySource?.uri.pathSegments.first) &&
element2?.name == 'DocumentReference' &&
.contains(element?.librarySource?.uri.pathSegments.first) &&
element?.name == 'DocumentReference' &&
(this as InterfaceType).typeArguments.single.isDartCoreMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class ${data.queryReferenceImplName}

extension on TypeProvider {
DartType asNullable(DartType type) {
final typeSystem = nullType.element2.library.typeSystem;
final typeSystem = nullType.element.library.typeSystem;
if (typeSystem.isNullable(type)) return type;

return typeSystem.leastUpperBound(type, nullType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ bool isValidatorAnnotation(ElementAnnotation annotation) {
final element = annotation.element;
if (element == null || element is! ConstructorElement) return false;

return element.enclosingElement3.allSupertypes.any((superType) {
return superType.element2.name == 'Validator' &&
superType.element2.librarySource.uri.toString() ==
return element.enclosingElement.allSupertypes.any((superType) {
return superType.element.name == 'Validator' &&
superType.element.librarySource.uri.toString() ==
'package:cloud_firestore_odm/src/validator.dart';
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:
sdk: ">=2.17.0 <3.0.0"

dependencies:
analyzer: ">=4.6.0 <6.0.0"
analyzer: ">=5.4.0 <6.0.0"
build: ^2.0.1
build_config: ^1.0.0
cloud_firestore_odm: ^1.0.0-dev.45
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -494,7 +494,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -541,7 +541,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -487,7 +487,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -534,7 +534,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -487,7 +487,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -534,7 +534,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Loading

0 comments on commit e0087c8

Please sign in to comment.