37 lines
1.1 KiB
Dart
37 lines
1.1 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||
|
||
part of 'games_dto.dart';
|
||
|
||
// **************************************************************************
|
||
// JsonSerializableGenerator
|
||
// **************************************************************************
|
||
|
||
GamesDto _$GamesDtoFromJson(Map<String, dynamic> json) => GamesDto(
|
||
data: (json['results'] as List<dynamic>?)
|
||
?.map((e) => GameDto.fromJson(e as Map<String, dynamic>))
|
||
.toList(),
|
||
current: getNextPageNumber(json['next']) != null ? getNextPageNumber(json['next'])! - 1 : null,
|
||
next: getNextPageNumber(json['next']),
|
||
);
|
||
|
||
int? getNextPageNumber(String url) {
|
||
RegExp regExp = RegExp(r'page=(\d+)');
|
||
Match? match = regExp.firstMatch(url);
|
||
String? number;
|
||
if (match != null) {
|
||
return int.parse(match.group(1)!);
|
||
}
|
||
//по умолчанию след. = 2, т.е. тек. = 1
|
||
else {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
GameDto _$GameDtoFromJson(Map<String, dynamic> json) => GameDto(
|
||
(json['id'] as num?)?.toInt(),
|
||
json['name'] as String?,
|
||
json['description'] as String?,
|
||
json['background_image'] as String?,
|
||
json['released'] as String?,
|
||
);
|