Skip to content

Commit d56141d

Browse files
authored
Upgrade to ffigen ^7.2 and remove unnecessary casts (#820)
1 parent d95a544 commit d56141d

File tree

6 files changed

+86239
-22192
lines changed

6 files changed

+86239
-22192
lines changed

pkgs/cupertino_http/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* `countOfBytesSent` property - the number of body bytes sent in the request.
1313
* `prefersIncrementalDelivery` property - whether to deliver the response
1414
body in one chunk (if possible) or many.
15+
* Upgrade to ffigen ^7.2.0 and remove unnecessary casts.
1516

1617
## 0.0.8
1718

pkgs/cupertino_http/ffigen.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Run with `dart run ffigen --config ffigen.yaml`.
1+
# Run with `flutter packages pub run ffigen --config ffigen.yaml`.
22
name: NativeCupertinoHttp
33
description: |
44
Bindings for the Foundation URL Loading System and supporting libraries.
55
6-
Regenerate bindings with `dart run ffigen --config ffigen.yaml`.
6+
Regenerate bindings with `flutter packages pub run ffigen --config ffigen.yaml`.
77
language: 'objc'
88
output: 'lib/src/native_cupertino_bindings.dart'
99
headers:

pkgs/cupertino_http/lib/cupertino_http.dart

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -558,14 +558,11 @@ class URLSessionTask extends _ObjectHolder<ncb.NSURLSessionTask> {
558558
///
559559
/// See [NSURLSessionTask.response](https://developer.apple.com/documentation/foundation/nsurlsessiontask/1410586-response)
560560
URLResponse? get response {
561-
if (_nsObject.response == null) {
561+
final nsResponse = _nsObject.response;
562+
if (nsResponse == null) {
562563
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!));
568564
}
565+
return URLResponse._exactURLResponseType(nsResponse);
569566
}
570567

571568
/// An error indicating why the task failed or `null` on success.
@@ -706,7 +703,7 @@ class URLRequest extends _ObjectHolder<ncb.NSURLRequest> {
706703
/// NOTE: The documentation for `NSURLRequest.HTTPMethod` says that the
707704
/// property is nullable but, in practice, assigning it to null will produce
708705
/// an error.
709-
String get httpMethod => toStringOrNull(_nsObject.HTTPMethod)!;
706+
String get httpMethod => _nsObject.HTTPMethod!.toString();
710707

711708
/// The timeout interval during the connection attempt.
712709
///
@@ -723,9 +720,7 @@ class URLRequest extends _ObjectHolder<ncb.NSURLRequest> {
723720
if (nsUrl == null) {
724721
return null;
725722
}
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());
729724
}
730725

731726
@override
@@ -864,10 +859,8 @@ void _setupDelegation(
864859
disposition = URLSessionResponseDisposition.urlSessionResponseAllow;
865860
break;
866861
}
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!);
871864

872865
try {
873866
disposition = onResponse(session, task, response);

0 commit comments

Comments
 (0)