Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.10.0

* Adds `WebResourceRequest` and `WebResourceResponse` to `HttpResponseError`.

## 2.9.1

* Updates minimum required plugin_platform_interface version to 2.1.7.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import 'package:flutter/foundation.dart';

import 'web_resource_request.dart';
import 'web_resource_response.dart';

/// Error returned in `PlatformNavigationDelegate.setOnHttpError` when an HTTP
/// response error has been received.
///
Expand Down Expand Up @@ -37,9 +40,13 @@ import 'package:flutter/foundation.dart';
class HttpResponseError {
/// Used by the platform implementation to create a new [HttpResponseError].
const HttpResponseError({
required this.statusCode,
this.request,
this.response,
});

/// The HTTP status code.
final int statusCode;
/// The associated request.
final WebResourceRequest? request;

/// The associated response.
final WebResourceResponse? response;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ export 'platform_webview_widget_creation_params.dart';
export 'scroll_position_change.dart';
export 'url_change.dart';
export 'web_resource_error.dart';
export 'web_resource_request.dart';
export 'web_resource_response.dart';
export 'webview_cookie.dart';
export 'webview_credential.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/foundation.dart';

/// Defines the parameters of the web resource request from the associated request.
///
/// Platform specific implementations can add additional fields by extending
/// this class.
///
/// This example demonstrates how to extend the [WebResourceRequest] to
/// provide additional platform specific parameters.
///
/// When extending [WebResourceRequest] additional parameters should always
/// accept `null` or have a default value to prevent breaking changes.
///
/// ```dart
/// class AndroidWebResourceRequest extends WebResourceRequest {
/// WebResourceRequest._({
/// required WebResourceRequest request,
/// }) : super(
/// uri: request.uri,
/// );
///
/// factory AndroidWebResourceRequest.fromWebResourceRequest(
/// WebResourceRequest request, {
/// Map<String, String> headers,
/// }) {
/// return AndroidWebResourceRequest._(request, headers: headers);
/// }
///
/// final Map<String, String> headers;
/// }
/// ```
@immutable
class WebResourceRequest {
/// Used by the platform implementation to create a new [WebResourceRequest].
const WebResourceRequest({required this.uri});

/// URI for the request.
final Uri uri;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/foundation.dart';

/// Contains information about the response for a request.
///
/// Platform specific implementations can add additional fields by extending
/// this class.
///
/// This example demonstrates how to extend the [WebResourceResponse] to
/// provide additional platform specific parameters.
///
/// When extending [WebResourceResponse] additional parameters should always
/// accept `null` or have a default value to prevent breaking changes.
///
/// ```dart
/// class AndroidWebResourceResponse extends WebResourceResponse {
/// WebResourceResponse._({
/// required WebResourceResponse response,
/// }) : super(
/// uri: response.uri,
/// statusCode: response.statusCode,
/// headers: response.headers,
/// );
///
/// factory AndroidWebResourceResponse.fromWebResourceResponse(
/// WebResourceResponse response, {
/// Uri? historyUrl,
/// }) {
/// return AndroidWebResourceResponse._(response, historyUrl: historyUrl);
/// }
///
/// final Uri? historyUrl;
/// }
/// ```
@immutable
class WebResourceResponse {
/// Used by the platform implementation to create a new [WebResourceResponse].
const WebResourceResponse({
required this.uri,
required this.statusCode,
this.headers = const <String, String>{},
});

/// The URI that this response is associated with.
final Uri? uri;

/// The HTTP status code.
final int statusCode;

/// Headers for the request.
final Map<String, String> headers;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/webview_flutt
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview_flutter%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.9.1
version: 2.10.0

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart'
as main_file;

void main() {
group('webview_flutter_platform_interface', () {
test(
'ensures webview_flutter_platform_interface.dart exports classes in types directory',
() {
// ignore: unnecessary_statements
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make this test its own file (e.g., webview_flutter_platform_interface_export_tests.dart), and then make this a file-level ignore, since a file that only tests exports wouldn't need to worry about losing lint coverage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. I will also make a mental note to do this for the webview_flutter package as well.

main_file.JavaScriptConsoleMessage;
// ignore: unnecessary_statements
main_file.JavaScriptLogLevel;
// ignore: unnecessary_statements
main_file.JavaScriptMessage;
// ignore: unnecessary_statements
main_file.JavaScriptMode;
// ignore: unnecessary_statements
main_file.LoadRequestMethod;
// ignore: unnecessary_statements
main_file.NavigationDecision;
// ignore: unnecessary_statements
main_file.NavigationRequest;
// ignore: unnecessary_statements
main_file.NavigationRequestCallback;
// ignore: unnecessary_statements
main_file.PageEventCallback;
// ignore: unnecessary_statements
main_file.PlatformNavigationDelegateCreationParams;
// ignore: unnecessary_statements
main_file.PlatformWebViewControllerCreationParams;
// ignore: unnecessary_statements
main_file.PlatformWebViewCookieManagerCreationParams;
// ignore: unnecessary_statements
main_file.PlatformWebViewPermissionRequest;
// ignore: unnecessary_statements
main_file.PlatformWebViewWidgetCreationParams;
// ignore: unnecessary_statements
main_file.ProgressCallback;
// ignore: unnecessary_statements
main_file.WebViewPermissionResourceType;
// ignore: unnecessary_statements
main_file.WebResourceRequest;
// ignore: unnecessary_statements
main_file.WebResourceResponse;
// ignore: unnecessary_statements
main_file.WebResourceError;
// ignore: unnecessary_statements
main_file.WebResourceErrorCallback;
// ignore: unnecessary_statements
main_file.WebViewCookie;
// ignore: unnecessary_statements
main_file.WebResourceErrorType;
// ignore: unnecessary_statements
main_file.UrlChange;
},
);
});
}