forked from eatvio/eatvio_app
81 lines
2.1 KiB
Dart
81 lines
2.1 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'feed_service.dart';
|
|
|
|
// **************************************************************************
|
|
// RetrofitGenerator
|
|
// **************************************************************************
|
|
|
|
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers
|
|
|
|
class _FeedService implements FeedService {
|
|
_FeedService(
|
|
this._dio, {
|
|
this.baseUrl,
|
|
});
|
|
|
|
final Dio _dio;
|
|
|
|
String? baseUrl;
|
|
|
|
@override
|
|
Future<List<FeedBlogPostModel>> getBlocPostList() async {
|
|
final _extra = <String, dynamic>{};
|
|
final queryParameters = <String, dynamic>{};
|
|
final _headers = <String, dynamic>{};
|
|
const Map<String, dynamic>? _data = null;
|
|
final _result = await _dio
|
|
.fetch<List<dynamic>>(_setStreamType<List<FeedBlogPostModel>>(Options(
|
|
method: 'GET',
|
|
headers: _headers,
|
|
extra: _extra,
|
|
)
|
|
.compose(
|
|
_dio.options,
|
|
'/feed/index',
|
|
queryParameters: queryParameters,
|
|
data: _data,
|
|
)
|
|
.copyWith(
|
|
baseUrl: _combineBaseUrls(
|
|
_dio.options.baseUrl,
|
|
baseUrl,
|
|
))));
|
|
var value = _result.data!
|
|
.map((dynamic i) =>
|
|
FeedBlogPostModel.fromJson(i as Map<String, dynamic>))
|
|
.toList();
|
|
return value;
|
|
}
|
|
|
|
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
|
if (T != dynamic &&
|
|
!(requestOptions.responseType == ResponseType.bytes ||
|
|
requestOptions.responseType == ResponseType.stream)) {
|
|
if (T == String) {
|
|
requestOptions.responseType = ResponseType.plain;
|
|
} else {
|
|
requestOptions.responseType = ResponseType.json;
|
|
}
|
|
}
|
|
return requestOptions;
|
|
}
|
|
|
|
String _combineBaseUrls(
|
|
String dioBaseUrl,
|
|
String? baseUrl,
|
|
) {
|
|
if (baseUrl == null || baseUrl.trim().isEmpty) {
|
|
return dioBaseUrl;
|
|
}
|
|
|
|
final url = Uri.parse(baseUrl);
|
|
|
|
if (url.isAbsolute) {
|
|
return url.toString();
|
|
}
|
|
|
|
return Uri.parse(dioBaseUrl).resolveUri(url).toString();
|
|
}
|
|
}
|