@@ -558,14 +558,11 @@ class URLSessionTask extends _ObjectHolder<ncb.NSURLSessionTask> {
558
558
///
559
559
/// See [NSURLSessionTask.response] (https://developer.apple.com/documentation/foundation/nsurlsessiontask/1410586-response)
560
560
URLResponse ? get response {
561
- if (_nsObject.response == null ) {
561
+ final nsResponse = _nsObject.response;
562
+ if (nsResponse == null ) {
562
563
return null ;
563
- } else {
564
- // TODO(https://github.com/dart-lang/ffigen/issues/373): remove cast
565
- // when precise type signatures are generated.
566
- return URLResponse ._exactURLResponseType (
567
- ncb.NSURLResponse .castFrom (_nsObject.response! ));
568
564
}
565
+ return URLResponse ._exactURLResponseType (nsResponse);
569
566
}
570
567
571
568
/// An error indicating why the task failed or `null` on success.
@@ -706,7 +703,7 @@ class URLRequest extends _ObjectHolder<ncb.NSURLRequest> {
706
703
/// NOTE: The documentation for `NSURLRequest.HTTPMethod` says that the
707
704
/// property is nullable but, in practice, assigning it to null will produce
708
705
/// an error.
709
- String get httpMethod => toStringOrNull ( _nsObject.HTTPMethod ) ! ;
706
+ String get httpMethod => _nsObject.HTTPMethod ! . toString () ;
710
707
711
708
/// The timeout interval during the connection attempt.
712
709
///
@@ -723,9 +720,7 @@ class URLRequest extends _ObjectHolder<ncb.NSURLRequest> {
723
720
if (nsUrl == null ) {
724
721
return null ;
725
722
}
726
- // TODO(https://github.com/dart-lang/ffigen/issues/373): remove NSObject
727
- // cast when precise type signatures are generated.
728
- return Uri .parse (toStringOrNull (ncb.NSURL .castFrom (nsUrl).absoluteString)! );
723
+ return Uri .parse (nsUrl.absoluteString! .toString ());
729
724
}
730
725
731
726
@override
@@ -864,10 +859,8 @@ void _setupDelegation(
864
859
disposition = URLSessionResponseDisposition .urlSessionResponseAllow;
865
860
break ;
866
861
}
867
- // TODO(https://github.com/dart-lang/ffigen/issues/373): remove cast
868
- // when precise type signatures are generated.
869
- final response = URLResponse ._exactURLResponseType (
870
- ncb.NSURLResponse .castFrom (forwardedResponse.response! ));
862
+ final response =
863
+ URLResponse ._exactURLResponseType (forwardedResponse.response! );
871
864
872
865
try {
873
866
disposition = onResponse (session, task, response);
0 commit comments