-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ketan Choyal
committed
May 17, 2023
1 parent
fabf838
commit 726ee95
Showing
22 changed files
with
341 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Publish to Pub.dev | |
|
||
on: | ||
push: | ||
branches: [beta] | ||
branches: [beta, master] | ||
|
||
jobs: | ||
publishing: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
part of mapbox_search; | ||
|
||
class BBox { | ||
Location min; | ||
Location max; | ||
final Location min; | ||
final Location max; | ||
|
||
BBox({ | ||
required this.min, | ||
required this.max, | ||
}); | ||
|
||
String get asString => '${min.lng},${min.lat},${max.lng},${max.lat}'; | ||
String get asString => min.asString + ',' + max.asString; | ||
|
||
List<double> get asList => [ | ||
...min.asList, | ||
...max.asList, | ||
]; | ||
|
||
factory BBox.fromJson(Map<String, dynamic> json) => BBox( | ||
min: ( | ||
long: json["bbox"][0], | ||
lat: json["bbox"][1], | ||
), | ||
max: ( | ||
long: json["bbox"][2], | ||
lat: json["bbox"][3], | ||
), | ||
); | ||
factory BBox.fromList(List<dynamic> list) => BBox( | ||
min: list.asLocation, | ||
max: list.sublist(2).asLocation, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
part of mapbox_search; | ||
|
||
class FailureResponse { | ||
final String? message; | ||
final String? error; | ||
final Map<String, dynamic> response; | ||
|
||
FailureResponse({ | ||
required this.message, | ||
required this.error, | ||
required this.response, | ||
}); | ||
|
||
factory FailureResponse.fromJson(Map<String, dynamic> json) => | ||
FailureResponse( | ||
message: json["message"], | ||
error: json["error"], | ||
response: json, | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
'message': message, | ||
'error': error, | ||
'response': response, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,45 @@ | ||
part of mapbox_search; | ||
|
||
abstract class Proximity {} | ||
typedef Location = ({double long, double lat}); | ||
|
||
extension on Location { | ||
String get asString => '$long,$lat'; | ||
|
||
List<double> get asList => [long, lat]; | ||
} | ||
|
||
extension on List { | ||
Location get asLocation => ( | ||
long: this[0] as double, | ||
lat: this[1] as double, | ||
); | ||
} | ||
|
||
sealed class Proximity { | ||
factory Proximity.LocationNone() => const _LocationNone(); | ||
factory Proximity.LocationIp() => const _LocationIp(); | ||
factory Proximity.Location(Location loc) => _Location(loc: loc); | ||
factory Proximity.LatLong({required double lat, required double long}) => | ||
_Location(loc: (long: long, lat: lat)); | ||
} | ||
|
||
/// A class that represents a location around which places will be searched. | ||
class Location implements Proximity { | ||
final double lat; | ||
final double lng; | ||
class _Location implements Proximity { | ||
final Location loc; | ||
|
||
const Location({ | ||
required this.lat, | ||
required this.lng, | ||
const _Location({ | ||
required this.loc, | ||
}); | ||
|
||
String get asString => '$lng,$lat'; | ||
String get asString => loc.asString; | ||
} | ||
|
||
/// A class that represents that no location based search will be performed. | ||
class LocationNone implements Proximity { | ||
const LocationNone(); | ||
class _LocationNone implements Proximity { | ||
const _LocationNone(); | ||
} | ||
|
||
/// A class that represents that the location will be based on the IP address of the user. | ||
class LocationIp implements Proximity { | ||
const LocationIp(); | ||
class _LocationIp implements Proximity { | ||
const _LocationIp(); | ||
} |
Oops, something went wrong.