This PR modifies the web build slightly to create an `AssetManifest.json`, that is a JSON(base64)-encoded version of the `AssetManifest.bin` file.
_(This should enable all browsers to download the file without any interference, and all servers to serve it with the correct headers.)_
It also modifies Flutter's `AssetManifest` class so it loads and uses said file `if (kIsWeb)`.
### Issues
* Fixes https://github.com/flutter/flutter/issues/124883
### Tests
* Unit tests added.
* Some tests that run on the Web needed to be informed of the new filename, but their behavior didn't have to change (binary contents are the same across all platforms).
* I've deployed a test app, so users affected by the BIN issue may take a look at the PR in action:
* https://dit-tests.web.app
This wraps up the platform view improvements discussed in https://github.com/flutter/flutter/issues/127030.
- Splits `HtmlElementView` into 2 files that are conditionally imported.
- The non-web version can be instantiated but it throws if it ends up being built in a widget tree.
- Out-of-the-box view factories that create visible & invisible DOM elements given a `tagName` parameter.
- New `HtmlElementView.fromTagName()` constructor that uses the default factories to create DOM elements.
- Tests covering the new API.
Depends on https://github.com/flutter/engine/pull/43828
Fixes https://github.com/flutter/flutter/issues/127030
The change in [0] has propagated now everywhere, so we can use
`utf8.encode()` instead of the longer `const Utf8Encoder.convert()`.
Also it cleans up code like
```
TypedData bytes;
bytes.buffer.asByteData();
```
as that is not guaranteed to be correct, the correct version would be
```
TypedData bytes;
bytes.buffer.asByteData(bytes.offsetInBytes, bytes.lengthInBytes);
```
a shorter hand for that is:
```
TypedData bytes;
ByteData.sublistView(bytes);
```
[0] https://github.com/dart-lang/sdk/issues/52801
Fixes https://github.com/flutter/flutter/issues/127090.
https://github.com/flutter/flutter/pull/122505 did a few things to speed up the first asset load that a flutter app performs. One of those things was to not include the main asset in its own list of variants in the asset manifest. The idea was that we know that the main asset always exists, so including it in its list of variants is a waste of storage space and loading time (even if the cost was tiny).
However, the assumption that the main asset always exists is wrong. From [Declaring resolution-aware image assets](https://docs.flutter.dev/ui/assets-and-images#resolution-aware), which predates https://github.com/flutter/flutter/pull/122505:
> Each entry in the asset section of the pubspec.yaml should correspond to a real file, with the exception of the main asset entry. If the main asset entry doesnât correspond to a real file, then the asset with the lowest resolution is used as the fallback for devices with device pixel ratios below that resolution. The entry should still be included in the pubspec.yaml manifest, however.
For example, it's valid to declare `assets/image.png` as an asset even if only `assets/3x/image.png` exists on disk.
This fix restores older behavior of including a main asset as a variant of itself in the manifest if it exists.
This fix also includes a non-user-visible behavior change:
* `"dpr"` is no longer a required field in the asset manifest's underlying structure. For the main asset entry, we do not include `"dpr"`. It makes less sense for the tool to decide what the default target dpr for an image should be. This should be left to the framework.
## Description
This fixes the parsing of `AppLifecycleState` in the services binding so that it knows what it is.
## Related Issues
- Fixes https://github.com/flutter/flutter/issues/127974
## Tests
- Added a test that causes parsing of all the different app lifecycle states.
## Description
This PR adds a new debug flag named `debugPrintKeyboardEvents` to help debugging keyboard issues.
Keyboard code has some useful asserts but sometimes an assertion failure is related to the handling of previous key events. This debug flag will help understanding the flow of key events which leads to an assertion failure.
## Related Issue
Fixes https://github.com/flutter/flutter/issues/125627
## Tests
Adds 1 test.
Related https://github.com/flutter/flutter/issues/100624
The goal is to make sure the engine can send a location string in either the existing format or a complete uri string to the framework, and the framework will still work as usual.
* Don't call `PlatformViewCreatedCallback`s after `AndroidViewController` is disposed
Before this change it was possible that, if a `AndroidViewController` was disposed before we got the notification that the platform view was created, `PlatformViewCreatedCallback`s where called even after calling `AndroidViewController.dispose`.
Also makes `_PlatformViewLinkState._onPlatformViewCreated` more carful to only call `setState` when mounted.
Closes#84628Closes#96384
* Allow all widgets to remove listeners from controller
* Remove assert
* Add expectations to test
* add asset manifest bin loading and asset manifest api
* use new api for image resolution
* remove upfront smc data casting
* fix typecasting issue
* remove unused import
* fix tests
* lints
* lints
* fix import
* revert image resolution changes
* Update image_resolution_test.dart
* Update decode_and_parse_asset_manifest.dart
* make targetDevicePixelRatio optional
* Update packages/flutter/lib/src/services/asset_manifest.dart
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
* Update packages/flutter/lib/src/services/asset_manifest.dart
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
* fix immutable not being imported
* return List in AssetManifest methods, fix annotation import
* simplify onError callback
* make AssetManifest methods abstract instead of throwing UnimplementedError
* simplify AssetVariant.key docstring
* tweak _AssetManifestBin docstring
* make AssetManifest and AssetVariant doc strings more specific
* use List.of instead of List.from for type-safety
* adjust import
* change _AssetManifestBin comment from doc comment to normal comment
* revert to callback function for onError in loadStructuredBinaryData
* add more to the docstring of AssetManifest.listAssets and AssetVariant.key
* add tests for CachingAssetBundle caching behavior
* add simple test to ensure loadStructuredBinaryData correctly calls load
* Update asset_manifest.dart
* update docstring for AssetManifest.getAssetVariants
* rename getAssetVariants, have it include main asset
* rename isMainAsset field of AssetMetadata to main
* (slightly) shorten name of describeAssetAndVariants
* rename describeAssetVariants back to getAssetVariants
* add tests for TestAssetBundle
* nits
* fix typo in docstring
* remove no longer necessary non-null asserts
* update gallery and google_fonts versions
---------
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
* Add support for image insertion on Android
* Fix checks
* Use proper Dart syntax on snippet
* Specify type annotation on list
* Fix nits, add some asserts, and improve example code
* Add missing import
* Fix nullsafety error
* Fix nullsafety error
* Remove reference to contentCommitMimeTypes in docs
* Fix nits
* Fix warnings and import
* Add test for content commit in editable_text_test.dart
* Check that URIs are equal in test
* Fix nits and rename functions / classes to be more self-explanatory
* Fix failing debugFillProperties tests
* Add empty implementation to `insertContent` in TextInputClient
* Tweak documentation slightly
* Improve docs for contentInsertionMimeTypes and fix assert
* Rework contentInsertionMimeType asserts
* Add test for onContentInserted example
* Switch implementation to a configuration class for more granularity in setting mime types
* Fix nits
* Improve docs and fix doc tests
* Fix more nits (LongCatIsLooong)
* Fix failing tests
* Make parameters (guaranteed by platform to be non-nullable) non-nullable
* Fix analysis issues
* attempt to extend to paragraph
* second attempt
* clean up implementation
* clean up
* updates
* updates
* Fix implementation
* remove old
* update docs
* update docs
* fix analyzer
* Fix bug where new line character was selected and backwards selection failed
* remove print
* Add test for paragraph boundary
* Add text editing test for extending selection to paragraph for mac and ios
* rename to ExtendSelectionToParagraphBoundaryIntent
* fix analyzer
* Should default to downstream when collapsing selection
* get rid of _getParagraphAtOffset and move into getTextBoundaryAt
* Search for all line terminators
* iterate through code units instead of characters
* Address some reviewer comments"
* Add separate implementations for leading and trailing paragraph boundary methods
* Do not break after a carriage return if it is followed by a line feed
* test carriage return followed by a line feed
* more tests
* Do not continue if the line terminator is at the target text offset
* add hack to extend highlight to line terminator
* Revert "add hack to extend highlight to line terminator"
This reverts commit b4d3c434539b66c3c81c215e87c645b425902825.
* Revert "Do not continue if the line terminator is at the target text offset"
This reverts commit 789e1b838e54e7c25600bfa8852e59431ccaf5dc.
* Update ParagraphBoundary with latest TextBoundary changes
* Update implementation to iterate through indexes
* update getTrailingTextBoundaryAt to include the line terminator
* Updates
* more updates
* more updates
* updates
* updates
* Lets try this again
* clean up
* updates
* more updates
* updates
* fix
* Re-implement using custom paragraph boundary applying method
* Revert "Re-implement using custom paragraph boundary applying method"
This reverts commit cd2f7f4b6eb6726b28f82a43708812e06a49df95.
* Revert "fix"
This reverts commit 8ec1f8f58935cfb3eb86dc6afd2894537af4cf7b.
* updates
* Revert "updates"
This reverts commit 9dcca4a0031fe18ada9d6ffbbe77ba09918e82ae.
* Revert "Revert "fix""
This reverts commit 9cc1332cd3041badc472d0d223a106203e46afb8.
* Revert "Revert "Re-implement using custom paragraph boundary applying method""
This reverts commit 1acb606fb743fd840da20cca26d9a7c26accb71d.
* Fix paragraph boundaries
* Add failing test
* Address some comments
* group tests and fix analyzer
* fix typo
* fix remaining test
* updates
* more fixes and logs
* clean up and add another test
* Fix last test
* Add new test
* Clean up
* more clean up
* clean up comments
* address comments
* updates
* return null when position is out of bounds and 0 or end of text if appropriate
* Clean up cases
* Do not return null when OOB in the direction of iteration
* clean up
* simplify implementation thanks to LongCatIsLooong feedback
* Address comments
* Add line and paragraph separator
* Use _moveBeyondTextBoundary instead of custom _moveToParagraphBoundary
* Change some intent names and revert fromPosition change
* clean up docs
---------
Co-authored-by: Renzo Olivares <roliv@google.com>
* add asset manifest bin loading and asset manifest api
* use new api for image resolution
* remove upfront smc data casting
* fix typecasting issue
* remove unused import
* fix tests
* lints
* lints
* fix import
* revert image resolution changes
* Update image_resolution_test.dart
* Update decode_and_parse_asset_manifest.dart
* make targetDevicePixelRatio optional
* Update packages/flutter/lib/src/services/asset_manifest.dart
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
* Update packages/flutter/lib/src/services/asset_manifest.dart
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
* fix immutable not being imported
* return List in AssetManifest methods, fix annotation import
* simplify onError callback
* make AssetManifest methods abstract instead of throwing UnimplementedError
* simplify AssetVariant.key docstring
* tweak _AssetManifestBin docstring
* make AssetManifest and AssetVariant doc strings more specific
* use List.of instead of List.from for type-safety
* adjust import
* change _AssetManifestBin comment from doc comment to normal comment
* revert to callback function for onError in loadStructuredBinaryData
* add more to the docstring of AssetManifest.listAssets and AssetVariant.key
* add tests for CachingAssetBundle caching behavior
* add simple test to ensure loadStructuredBinaryData correctly calls load
* Update asset_manifest.dart
* update docstring for AssetManifest.getAssetVariants
* rename getAssetVariants, have it include main asset
* rename isMainAsset field of AssetMetadata to main
* (slightly) shorten name of describeAssetAndVariants
* rename describeAssetVariants back to getAssetVariants
* add tests for TestAssetBundle
* nits
* fix typo in docstring
* remove no longer necessary non-null asserts
Co-authored-by: Jonah Williams <jonahwilliams@google.com>