From 4f943bbde3d93ef80ab16278bdcfd3e974ecef58 Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Mon, 12 Jun 2023 13:27:46 +1000 Subject: [PATCH] `next_gen_ui_demo`: Add `dispose` handler for `Picture`s (#1889) ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/wiki/Chat [Contributors Guide]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md --- next_gen_ui_demo/lib/common/shader_effect.dart | 10 ++++++++-- next_gen_ui_demo/pubspec.yaml | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/next_gen_ui_demo/lib/common/shader_effect.dart b/next_gen_ui_demo/lib/common/shader_effect.dart index 86db665f1..0caa7394b 100644 --- a/next_gen_ui_demo/lib/common/shader_effect.dart +++ b/next_gen_ui_demo/lib/common/shader_effect.dart @@ -283,10 +283,10 @@ class _RenderShaderSamplerBuilderWidget extends RenderProxyBox { @override void paint(PaintingContext context, Offset offset) { - if (size.isEmpty || !_enabled) { + if (size.isEmpty) { return; } - assert(offset == Offset.zero); + assert(!_enabled || offset == Offset.zero); return super.paint(context, offset); } } @@ -359,4 +359,10 @@ class _ShaderSamplerBuilderLayer extends OffsetLayer { _lastPicture = pictureRecorder.endRecording(); builder.addPicture(offset, _lastPicture!); } + + @override + void dispose() { + _lastPicture?.dispose(); + super.dispose(); + } } diff --git a/next_gen_ui_demo/pubspec.yaml b/next_gen_ui_demo/pubspec.yaml index 0a0cf36ed..a2c7f0fb2 100644 --- a/next_gen_ui_demo/pubspec.yaml +++ b/next_gen_ui_demo/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: 'none' version: 0.1.0 environment: - sdk: '>=3.0.0-417.4.beta <4.0.0' + sdk: ^3.0.0 dependencies: cupertino_icons: ^1.0.5