Skip to content

Commit b21dce5

Browse files
authored
[web] Updates package:web dependency to ^0.5.0. (flutter#5791)
This PR updates the packages that are using `package:web` to version `^0.5.0`. Ancilliary changes: * Bump `environment` to `flutter: ">=3.19.0"` and `sdk: ^3.3.0`. * Bump version to next `Y` * Clean-up code that was kept for compatibility with versions of `web: <0.5.0`. The main exception to this is `package:google_sign_in_web`, which depends on a version of `google_identity_services_web` that has a dependency on package:web that is `<0.5.0`, so that package needs to have a range until `google_identity_services_web` gets published with the new ^0.5.0 dependency. Co-Authored-By: David Iglesias<[email protected]>
1 parent 8bba41b commit b21dce5

File tree

44 files changed

+500
-290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+500
-290
lines changed

packages/cross_file/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## NEXT
1+
## 0.3.4
22

3-
* Updates minimum supported SDK version to Flutter 3.13/Dart 3.1.
3+
* Updates to web code to package `web: ^0.5.0`.
4+
* Updates SDK version to Dart `^3.3.0`.
45

56
## 0.3.3+8
67

packages/cross_file/lib/src/types/html.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ class XFile extends XFileBase {
6666
super(path) {
6767
if (path == null) {
6868
_browserBlob = _createBlobFromBytes(bytes, mimeType);
69-
// TODO(kevmoo): drop ignore when pkg:web constraint excludes v0.3
70-
// ignore: unnecessary_cast
71-
_path = URL.createObjectURL(_browserBlob! as JSObject);
69+
_path = URL.createObjectURL(_browserBlob!);
7270
} else {
7371
_path = path;
7472
}
@@ -131,9 +129,7 @@ class XFile extends XFileBase {
131129

132130
// Attempt to re-hydrate the blob from the `path` via a (local) HttpRequest.
133131
// Note that safari hangs if the Blob is >=4GB, so bail out in that case.
134-
// TODO(kevmoo): Remove ignore and fix when the MIN Dart SDK is 3.3
135-
// ignore: unnecessary_non_null_assertion
136-
if (isSafari() && _length != null && _length! >= _fourGigabytes) {
132+
if (isSafari() && _length != null && _length >= _fourGigabytes) {
137133
throw Exception('Safari cannot handle XFiles larger than 4GB.');
138134
}
139135

packages/cross_file/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ name: cross_file
22
description: An abstraction to allow working with files across multiple platforms.
33
repository: https://github.com/flutter/packages/tree/main/packages/cross_file
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+cross_file%22
5-
version: 0.3.3+8
5+
version: 0.3.4
66

77
environment:
8-
sdk: ^3.2.0
8+
sdk: ^3.3.0
99

1010
dependencies:
1111
meta: ^1.3.0
12-
web: '>=0.3.0 <0.5.0'
12+
web: ^0.5.0
1313

1414
dev_dependencies:
1515
path: ^1.8.1

packages/cross_file/test/x_file_html_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ void main() {
6969
test('Stores data as a Blob', () async {
7070
// Read the blob from its path 'natively'
7171
final html.Response response =
72-
(await html.window.fetch(file.path.toJS).toDart)! as html.Response;
72+
await html.window.fetch(file.path.toJS).toDart;
7373

74-
final JSAny? arrayBuffer = await response.arrayBuffer().toDart;
75-
final ByteBuffer data = (arrayBuffer! as JSArrayBuffer).toDart;
74+
final JSAny arrayBuffer = await response.arrayBuffer().toDart;
75+
final ByteBuffer data = (arrayBuffer as JSArrayBuffer).toDart;
7676
expect(data.asUint8List(), equals(bytes));
7777
});
7878

packages/file_selector/file_selector_web/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## NEXT
1+
## 0.9.4
22

3-
* Updates minimum supported SDK version to Flutter 3.13/Dart 3.1.
3+
* Updates web code to package `web: ^0.5.0`.
4+
* Updates SDK version to Dart `^3.3.0`. Flutter `^3.16.0`.
45

56
## 0.9.3
67

packages/file_selector/file_selector_web/example/integration_test/dom_helper_test.dart

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ void main() {
1818

1919
FileList? createFileList(List<File> files) {
2020
final DataTransfer dataTransfer = DataTransfer();
21+
// Tear-offs of external extension type interop member 'add' are disallowed.
22+
// ignore: prefer_foreach
2123
for (final File e in files) {
22-
// TODO(srujzs): This is necessary in order to support package:web 0.4.0.
23-
// This was not needed with 0.3.0, hence the lint.
24-
// ignore: unnecessary_cast
25-
dataTransfer.items.add(e as JSAny);
24+
dataTransfer.items.add(e);
2625
}
2726
return dataTransfer.files;
2827
}
@@ -46,13 +45,8 @@ void main() {
4645
});
4746

4847
group('getFiles', () {
49-
final File mockFile1 =
50-
// TODO(srujzs): Remove once typed JSArrays (JSArray<T>) get to `stable`.
51-
// ignore: always_specify_types
52-
File(<Object>['123456'].jsify as JSArray, 'file1.txt');
53-
// TODO(srujzs): Remove once typed JSArrays (JSArray<T>) get to `stable`.
54-
// ignore: always_specify_types
55-
final File mockFile2 = File(<Object>[].jsify as JSArray, 'file2.txt');
48+
final File mockFile1 = File(<JSAny>['123456'.toJS].toJS, 'file1.txt');
49+
final File mockFile2 = File(<JSAny>[].toJS, 'file2.txt');
5650

5751
testWidgets('works', (_) async {
5852
final Future<List<XFile>> futureFiles = domHelper.getFiles(
@@ -114,32 +108,27 @@ void main() {
114108
testWidgets('sets the <input /> attributes and clicks it', (_) async {
115109
const String accept = '.jpg,.png';
116110
const bool multiple = true;
117-
bool wasClicked = false;
118-
119-
//ignore: unawaited_futures
120-
input.onClick.first.then((_) => wasClicked = true);
111+
final Future<bool> wasClicked = input.onClick.first.then((_) => true);
121112

122113
final Future<List<XFile>> futureFile = domHelper.getFiles(
123114
accept: accept,
124115
multiple: multiple,
125116
input: input,
126117
);
127118

128-
expect(input.matches('body'), true);
119+
expect(input.isConnected, true,
120+
reason: 'input must be injected into the DOM');
129121
expect(input.accept, accept);
130122
expect(input.multiple, multiple);
131-
expect(
132-
wasClicked,
133-
true,
134-
reason:
135-
'The <input /> should be clicked otherwise no dialog will be shown',
136-
);
123+
expect(await wasClicked, true,
124+
reason:
125+
'The <input /> should be clicked otherwise no dialog will be shown');
137126

138127
setFilesAndTriggerChange(<File>[]);
139128
await futureFile;
140129

141130
// It should be already removed from the DOM after the file is resolved.
142-
expect(input.parentElement, isNull);
131+
expect(input.isConnected, isFalse);
143132
});
144133
});
145134
});

packages/file_selector/file_selector_web/example/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ name: file_selector_web_integration_tests
22
publish_to: none
33

44
environment:
5-
sdk: ^3.1.0
6-
flutter: ">=3.13.0"
5+
sdk: ^3.3.0
6+
flutter: ">=3.19.0"
77

88
dependencies:
99
file_selector_platform_interface: ^2.6.0
1010
file_selector_web:
1111
path: ../
1212
flutter:
1313
sdk: flutter
14-
web: '>=0.3.0 <0.5.0'
14+
web: ^0.5.0
1515

1616
dev_dependencies:
1717
flutter_test:

packages/file_selector/file_selector_web/lib/src/dom_helper.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import 'package:web/helpers.dart';
1414
class DomHelper {
1515
/// Default constructor, initializes the container DOM element.
1616
DomHelper() {
17-
final Element body = querySelector('body')!;
17+
final Element body = document.querySelector('body')!;
1818
body.appendChild(_container);
1919
}
2020

21-
final Element _container = createElementTag('file-selector');
21+
final Element _container = document.createElement('file-selector');
2222

2323
/// Sets the <input /> attributes and waits for a file to be selected.
2424
Future<List<XFile>> getFiles({
@@ -28,7 +28,7 @@ class DomHelper {
2828
}) {
2929
final Completer<List<XFile>> completer = Completer<List<XFile>>();
3030
final HTMLInputElement inputElement =
31-
input ?? (createElementTag('input') as HTMLInputElement)
31+
input ?? (document.createElement('input') as HTMLInputElement)
3232
..type = 'file';
3333

3434
_container.appendChild(
@@ -72,10 +72,7 @@ class DomHelper {
7272
}
7373

7474
XFile _convertFileToXFile(File file) => XFile(
75-
// TODO(srujzs): This is necessary in order to support package:web 0.4.0.
76-
// This was not needed with 0.3.0, hence the lint.
77-
// ignore: unnecessary_cast
78-
URL.createObjectURL(file as JSObject),
75+
URL.createObjectURL(file),
7976
name: file.name,
8077
length: file.size,
8178
lastModified: DateTime.fromMillisecondsSinceEpoch(file.lastModified),

packages/file_selector/file_selector_web/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: file_selector_web
22
description: Web platform implementation of file_selector
33
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_web
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
5-
version: 0.9.3
5+
version: 0.9.4
66

77
environment:
8-
sdk: ^3.2.0
9-
flutter: ">=3.16.0"
8+
sdk: ^3.3.0
9+
flutter: ">=3.19.0"
1010

1111
flutter:
1212
plugin:
@@ -22,7 +22,7 @@ dependencies:
2222
sdk: flutter
2323
flutter_web_plugins:
2424
sdk: flutter
25-
web: '>=0.3.0 <0.5.0'
25+
web: ^0.5.0
2626

2727
dev_dependencies:
2828
flutter_test:

packages/google_identity_services_web/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.3.1
2+
3+
* Updates web code to package `web: ^0.5.0`.
4+
* Updates SDK version to Dart `^3.3.0`. Flutter `^3.19.0`.
5+
16
## 0.3.0+2
27

38
* Adds `fedcm_auto` to `CredentialSelectBy` enum.

0 commit comments

Comments
 (0)