Unverified Commit 71c45709 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Add ResizeImage.policy (#121154)

* Add ResizeImage.policy

This adds a new `ResizeImage.policy` property that controls how `ResizeImage`
will interpret its `width` and `height` properties. The existing behavior is
preserved via `ResizeImagePolicy.exact` (default), but there is now the option
to use `ResizeImagePolicy.fit`, which satisfies the use case outlined in
flutter/flutter#118543.

The API doc assets were added in flutter/assets-for-api-docs#209

Fixes flutter/flutter#118543

* Docuemnt public member

* Remove protected annotation from overrides - was failing tests

* Fixed analysis of code in Dartdoc

* More dartdoc code analysis fixes

* One more fix

* Review comments
parent 9619c333
...@@ -48,7 +48,7 @@ const List<int> kAnimatedGif = <int> [ ...@@ -48,7 +48,7 @@ const List<int> kAnimatedGif = <int> [
// Constructed by the following code: // Constructed by the following code:
// ```dart // ```dart
// Future<void> someTest(WidgetTester tester) async { // Future<void> someTest(WidgetTester tester) async {
// Uint8List bytes; // Uint8List? bytes;
// await tester.runAsync(() async { // await tester.runAsync(() async {
// const int imageWidth = 100; // const int imageWidth = 100;
// const int imageHeight = 100; // const int imageHeight = 100;
...@@ -60,9 +60,9 @@ const List<int> kAnimatedGif = <int> [ ...@@ -60,9 +60,9 @@ const List<int> kAnimatedGif = <int> [
// ui.decodeImageFromPixels( // ui.decodeImageFromPixels(
// pixels, imageWidth, imageHeight, ui.PixelFormat.rgba8888, // pixels, imageWidth, imageHeight, ui.PixelFormat.rgba8888,
// (ui.Image image) async { // (ui.Image image) async {
// final ByteData byteData = await image.toByteData( // final ByteData? byteData = await image.toByteData(
// format: ui.ImageByteFormat.png); // format: ui.ImageByteFormat.png);
// bytes = byteData.buffer.asUint8List(); // bytes = byteData!.buffer.asUint8List();
// completer.complete(); // completer.complete();
// }, // },
// ); // );
...@@ -91,3 +91,35 @@ const List<int> kBlueRectPng = <int> [ ...@@ -91,3 +91,35 @@ const List<int> kBlueRectPng = <int> [
99, 72, 140, 33, 49, 134, 196, 24, 18, 99, 72, 204, 5, 234, 78, 2, 198, 180, 99, 72, 140, 33, 49, 134, 196, 24, 18, 99, 72, 204, 5, 234, 78, 2, 198, 180,
170, 48, 200, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130, 170, 48, 200, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130,
]; ];
/// A portrait-mode (50x100) PNG with blue pixels.
const List<int> kBluePortraitPng = <int> [
137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 50, 0,
0, 0, 100, 8, 6, 0, 0, 0, 196, 232, 99, 91, 0, 0, 0, 4, 115, 66, 73, 84, 8, 8,
8, 8, 124, 8, 100, 136, 0, 0, 0, 140, 73, 68, 65, 84, 120, 156, 237, 207, 1,
13, 192, 48, 12, 192, 176, 126, 252, 57, 247, 36, 46, 45, 186, 108, 4, 201,
51, 179, 59, 63, 112, 110, 7, 124, 197, 72, 141, 145, 26, 35, 53, 70, 106,
140, 212, 24, 169, 49, 82, 99, 164, 198, 72, 141, 145, 26, 35, 53, 70, 106,
140, 212, 24, 169, 49, 82, 99, 164, 198, 72, 141, 145, 26, 35, 53, 70, 106,
140, 212, 24, 169, 49, 82, 99, 164, 198, 72, 141, 145, 26, 35, 53, 70, 106,
140, 212, 24, 169, 49, 82, 99, 164, 198, 72, 141, 145, 26, 35, 53, 70, 106,
140, 212, 24, 169, 49, 82, 99, 164, 198, 72, 141, 145, 26, 35, 53, 70, 106,
140, 212, 24, 169, 49, 82, 99, 164, 198, 72, 205, 11, 105, 8, 2, 198, 99, 140,
153, 87, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130,
];
/// A landscape-mode (100x50) PNG with blue pixels.
const List<int> kBlueLandscapePng = <int> [
137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 100, 0,
0, 0, 50, 8, 6, 0, 0, 0, 170, 53, 126, 190, 0, 0, 0, 4, 115, 66, 73, 84, 8, 8,
8, 8, 124, 8, 100, 136, 0, 0, 0, 143, 73, 68, 65, 84, 120, 156, 237, 209, 65,
13, 0, 32, 16, 192, 176, 3, 255, 158, 225, 141, 2, 246, 104, 21, 44, 217, 154,
57, 103, 200, 216, 191, 3, 120, 25, 18, 99, 72, 140, 33, 49, 134, 196, 24, 18,
99, 72, 140, 33, 49, 134, 196, 24, 18, 99, 72, 140, 33, 49, 134, 196, 24, 18,
99, 72, 140, 33, 49, 134, 196, 24, 18, 99, 72, 140, 33, 49, 134, 196, 24, 18,
99, 72, 140, 33, 49, 134, 196, 24, 18, 99, 72, 140, 33, 49, 134, 196, 24, 18,
99, 72, 140, 33, 49, 134, 196, 24, 18, 99, 72, 140, 33, 49, 134, 196, 24, 18,
99, 72, 140, 33, 49, 134, 196, 24, 18, 99, 72, 140, 33, 49, 134, 196, 24, 18,
99, 72, 140, 33, 49, 134, 196, 92, 164, 190, 2, 98, 53, 3, 99, 174, 0, 0, 0,
0, 73, 69, 78, 68, 174, 66, 96, 130,
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment