Skip to content

Commit

Permalink
Implement PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
flikkr committed Jul 25, 2024
1 parent a3759e5 commit a395bbb
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 45 deletions.
8 changes: 3 additions & 5 deletions flutter_google_places_sdk_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
## 0.3.0

* BREAKING: Rename `RankPreference` to `TextSearchRankPreference` and introduce `NearbySearchRankPreference`
* FEAT: Added support for Google Places (new) which can be enabled through `initialize` function.
* FEAT: Added `searchByText` function for Places (new).
* FEAT: Added `searchNearby` function for Places (new).
* FEAT: Added `nameLanguageCode` and `reviews` to Place object.
* feat: Added support for Google Places (new) which can be enabled through `initialize` function.
* feat: Added `searchByText` and `searchNearby` function for Places (new).
* feat: Added `nameLanguageCode` and `reviews` to Place object.

## 0.2.7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ linter:
- always_declare_return_types
- always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- always_require_non_null_named_parameters
# - always_specify_types
- annotate_overrides
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
Expand Down Expand Up @@ -106,10 +107,12 @@ linter:
- hash_and_equals
- implementation_imports
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
- iterable_contains_unrelated_type
# - join_return_with_assignment # not yet tested
- library_names
- library_prefixes
# - lines_longer_than_80_chars # not yet tested
- list_remove_unrelated_type
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
# - missing_whitespace_between_adjacent_strings # not yet tested
- no_adjacent_strings_in_list
Expand Down Expand Up @@ -138,6 +141,7 @@ linter:
# - prefer_constructors_over_static_methods # not yet tested
- prefer_contains
# - prefer_double_quotes # opposite of prefer_single_quotes
- prefer_equal_for_default_values
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
- prefer_final_fields
- prefer_final_in_for_each
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ abstract class FlutterGooglePlacesSdkPlatform extends PlatformInterface {

/// "Powered by google" image that should be used when background is white
static const AssetImage ASSET_POWERED_BY_GOOGLE_ON_WHITE = AssetImage(
'assets/google/powered_by_google_on_white.png',
package: 'flutter_google_places_sdk_platform_interface',
);
'assets/google/powered_by_google_on_white.png',
package: 'flutter_google_places_sdk_platform_interface');

/// "Powered by google" image that should be used when background is not white
static const AssetImage ASSET_POWERED_BY_GOOGLE_ON_NON_WHITE = AssetImage(
'assets/google/powered_by_google_on_non_white.png',
package: 'flutter_google_places_sdk_platform_interface',
);
'assets/google/powered_by_google_on_non_white.png',
package: 'flutter_google_places_sdk_platform_interface');

static final Object _token = Object();

static FlutterGooglePlacesSdkPlatform _instance = FlutterGooglePlacesSdkMethodChannel();
static FlutterGooglePlacesSdkPlatform _instance =
FlutterGooglePlacesSdkMethodChannel();

/// Singleton instance to the platform
static FlutterGooglePlacesSdkPlatform get instance => _instance;
Expand Down Expand Up @@ -86,7 +85,8 @@ abstract class FlutterGooglePlacesSdkPlatform extends PlatformInterface {
LatLngBounds? locationBias,
LatLngBounds? locationRestriction,
}) {
throw UnimplementedError('findAutocompletePredictions() has not been implemented.');
throw UnimplementedError(
'findAutocompletePredictions() has not been implemented.');
}

/// Fetches the details of a place.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const String _CHANNEL_NAME = 'plugins.msh.com/flutter_google_places_sdk';
const MethodChannel _channel = MethodChannel(_CHANNEL_NAME);

/// An implementation of [FlutterGooglePlacesSdkPlatform] that uses method channels.
class FlutterGooglePlacesSdkMethodChannel extends FlutterGooglePlacesSdkPlatform {
class FlutterGooglePlacesSdkMethodChannel
extends FlutterGooglePlacesSdkPlatform {
static const CHANNEL_NAME = _CHANNEL_NAME;

@override
Expand Down Expand Up @@ -107,7 +108,8 @@ class FlutterGooglePlacesSdkMethodChannel extends FlutterGooglePlacesSdkPlatform
}

FetchPlaceResponse _responseFromPlaceDetails(dynamic value) {
final place = value == null ? null : Place.fromJson(value.cast<String, dynamic>());
final Place? place =
value == null ? null : Place.fromJson(value.cast<String, dynamic>());
return FetchPlaceResponse(place);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'author_attribution.freezed.dart';
part 'author_attribution.g.dart';

@freezed
@Freezed()
class AuthorAttribution with _$AuthorAttribution {
/// Constructs a [AuthorAttribution] object.
const factory AuthorAttribution({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter_google_places_sdk_platform_interface/src/types/lat_lng.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'circular_bounds.freezed.dart';
part 'circular_bounds.g.dart';

/// An immutable class representing a latitude/longitude aligned circle, with a defined radius.
@Freezed()
class CircularBounds with _$CircularBounds {
/// constructs a [CircularBounds] object.
const factory CircularBounds({
required LatLng center,
required double radius,
}) = _CircularBounds;

/// Parse an [CircularBounds] from json.
factory CircularBounds.fromJson(Map<String, Object?> json) =>
_$CircularBoundsFromJson(json);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,3 @@ class LatLngBounds with _$LatLngBounds {
factory LatLngBounds.fromJson(Map<String, Object?> json) =>
_$LatLngBoundsFromJson(json);
}

/// An immutable class representing a latitude/longitude aligned circle, with a defined radius.
@Freezed()
class CircularBounds with _$CircularBounds {
/// constructs a [CircularBounds] object.
const factory CircularBounds({
required LatLng center,
required double radius,
}) = _CircularBounds;

/// Parse an [CircularBounds] from json.
factory CircularBounds.fromJson(Map<String, Object?> json) =>
_$CircularBoundsFromJson(json);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@ enum PlaceTypeFilter {
}

extension PlaceTypeFilterDescriptor on PlaceTypeFilter {
@Deprecated('Use `name` instead')
String get value => describeEnum(this);
String get value => name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ enum NearbySearchRankPreference {
}
}

extension NearbySearcRankPreferenceValue on NearbySearchRankPreference {
extension NearbySearchRankPreferenceValue on NearbySearchRankPreference {
String get value => _$NearbySearchRankPreferenceEnumMap[this]!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'review.freezed.dart';
part 'review.g.dart';

@freezed
@Freezed()
class Review with _$Review {
/// Constructs a [Review] object.
const factory Review({
Expand All @@ -14,12 +14,6 @@ class Review with _$Review {
/// This review's AuthorAttribution.
required AuthorAttribution authorAttribution,

/// The text of the review in its original language.
String? originalText,

/// The language code of the original text of the review.
String? originalTextLanguageCode,

/// A whole number between 1.0 and 5.0 (inclusive), meaning the number of stars.
required double rating,

Expand All @@ -29,6 +23,12 @@ class Review with _$Review {
/// A human-readable description of the relative publish time of a review, such as "a month ago", or "in the last week", based on the time elapsed.
required String relativePublishTimeDescription,

/// The text of the review in its original language.
String? originalText,

/// The language code of the original text of the review.
String? originalTextLanguageCode,

/// The text of the review.
String? text,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'search_by_text_response.freezed.dart';

/// The response for a [FlutterGooglePlacesSdkPlatform.searchByText] request
@freezed
@Freezed()
class SearchByTextResponse with _$SearchByTextResponse {
/// constructs a [SearchByTextResponse] object.
const factory SearchByTextResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'search_nearby_response.freezed.dart';

/// The response for a [FlutterGooglePlacesSdkPlatform.searchNearby] request
@freezed
@Freezed()
class SearchNearbyResponse with _$SearchNearbyResponse {
/// constructs a [SearchNearbyResponse] object.
const factory SearchNearbyResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export 'address_component.dart';
export 'author_attribution.dart';
export 'autocomplete_predictions.dart';
export 'business_status.dart';
export 'circular_bounds.dart';
export 'day_of_week.dart';
export 'fetch_photo_response.dart';
export 'fetch_place_response.dart';
Expand Down
2 changes: 1 addition & 1 deletion flutter_google_places_sdk_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
sdk: flutter
freezed_annotation: ^2.4.1
json_annotation: ^4.8.1
plugin_platform_interface: ^2.1.8
plugin_platform_interface: ^2.1.6

dev_dependencies:
build_runner: ^2.4.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ class FlutterGooglePlacesSdkPlatformMock extends Mock
with MockPlatformInterfaceMixin
implements FlutterGooglePlacesSdkPlatform {}

class ImplementsFlutterGooglePlacesSdkPlatform extends Mock implements FlutterGooglePlacesSdkPlatform {}
class ImplementsFlutterGooglePlacesSdkPlatform extends Mock
implements FlutterGooglePlacesSdkPlatform {}

class ExtendsFlutterGooglePlacesSdkPlatform extends FlutterGooglePlacesSdkPlatform {}
class ExtendsFlutterGooglePlacesSdkPlatform
extends FlutterGooglePlacesSdkPlatform {}

0 comments on commit a395bbb

Please sign in to comment.