forked from hiddify/hiddify-app
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
b86cd26
commit 37dc336
Showing
6 changed files
with
136 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import 'package:dart_mappable/dart_mappable.dart'; | ||
|
||
part 'ip_info_entity.mapper.dart'; | ||
|
||
@MappableClass() | ||
class IpInfo with IpInfoMappable { | ||
const IpInfo({ | ||
required this.ip, | ||
required this.countryCode, | ||
required this.region, | ||
required this.city, | ||
this.timezone, | ||
this.asn, | ||
this.org, | ||
}); | ||
|
||
final String ip; | ||
final String countryCode; | ||
final String region; | ||
final String city; | ||
final String? timezone; | ||
final String? asn; | ||
final String? org; | ||
|
||
static IpInfo fromIpInfoIoJson(Map<String, dynamic> json) { | ||
return switch (json) { | ||
{ | ||
"ip": final String ip, | ||
"country": final String country, | ||
"region": final String region, | ||
"city": final String city, | ||
"timezone": final String timezone, | ||
"org": final String org, | ||
} => | ||
IpInfo( | ||
ip: ip, | ||
countryCode: country, | ||
region: region, | ||
city: city, | ||
timezone: timezone, | ||
org: org, | ||
), | ||
_ => throw const FormatException("invalid json"), | ||
}; | ||
} | ||
|
||
static IpInfo fromIpApiCoJson(Map<String, dynamic> json) { | ||
return switch (json) { | ||
{ | ||
"ip": final String ip, | ||
"country_code": final String countryCode, | ||
"region": final String region, | ||
"city": final String city, | ||
"timezone": final String timezone, | ||
"asn": final String asn, | ||
"org": final String org, | ||
} => | ||
IpInfo( | ||
ip: ip, | ||
countryCode: countryCode, | ||
region: region, | ||
city: city, | ||
timezone: timezone, | ||
asn: asn, | ||
org: org, | ||
), | ||
_ => throw const FormatException("invalid json"), | ||
}; | ||
} | ||
} |
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