Open dickermoshe opened 4 months ago
Describe the bug If you use a nullable property it is not type checked
To Reproduce
import 'dart:io'; import 'package:dio/dio.dart'; import 'package:retrofit/retrofit.dart'; part 'client_client.g.dart'; @RestApi() abstract class ClientClient { factory ClientClient(Dio dio, {String? baseUrl}) = _ClientClient; /// test upload. /// /// upload test. @POST('/test/upload') Future<void> testUpload({ @Body() required File requiredBody, }); }
Results in:
@override Future<void> testUpload({File? nullableBody}) async { final _extra = <String, dynamic>{}; final queryParameters = <String, dynamic>{}; queryParameters.removeWhere((k, v) => v == null); final _headers = <String, dynamic>{}; final _data = Stream.fromIterable(nullableBody.readAsBytesSync().map((i) => [i])); // This should be checked for null !! await _dio.fetch<void>(_setStreamType<void>(Options( method: 'POST', headers: _headers, extra: _extra, ) .compose( _dio.options, '/test/upload', queryParameters: queryParameters, data: _data, ) .copyWith( baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, )))); }
Expected behavior Should check for null
Describe the bug If you use a nullable property it is not type checked
To Reproduce
Results in:
Expected behavior Should check for null