Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
1a2c3151
Unverified
Commit
1a2c3151
authored
Jan 14, 2024
by
Kostia Sokolovskyi
Committed by
GitHub
Jan 14, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BoxPainter should dispatch creation and disposal events. (#141526)
parent
947d7cad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
decoration.dart
packages/flutter/lib/src/painting/decoration.dart
+17
-4
decoration_test.dart
packages/flutter/test/painting/decoration_test.dart
+13
-0
No files found.
packages/flutter/lib/src/painting/decoration.dart
View file @
1a2c3151
...
...
@@ -198,9 +198,18 @@ abstract class Decoration with Diagnosticable {
/// happens, the [onChanged] callback will be invoked. To stop this callback
/// from being called after the painter has been discarded, call [dispose].
abstract
class
BoxPainter
{
/// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const
BoxPainter
([
this
.
onChanged
]);
/// Default abstract constructor for box painters.
BoxPainter
([
this
.
onChanged
])
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
FlutterMemoryAllocations
.
instance
.
dispatchObjectCreated
(
library
:
'package:flutter/painting.dart'
,
className:
'
$BoxPainter
'
,
object:
this
,
);
}
}
/// Paints the [Decoration] for which this object was created on the
/// given canvas using the given configuration.
...
...
@@ -243,5 +252,9 @@ abstract class BoxPainter {
/// The [onChanged] callback will not be invoked after this method has been
/// called.
@mustCallSuper
void
dispose
()
{
}
void
dispose
()
{
if
(
kFlutterMemoryAllocationsEnabled
)
{
FlutterMemoryAllocations
.
instance
.
dispatchObjectDisposed
(
object:
this
);
}
}
}
packages/flutter/test/painting/decoration_test.dart
View file @
1a2c3151
...
...
@@ -9,6 +9,7 @@ import 'package:fake_async/fake_async.dart';
import
'package:flutter/foundation.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'../image_data.dart'
;
import
'../painting/mocks_for_image_cache.dart'
;
...
...
@@ -813,4 +814,16 @@ void main() {
info
.
dispose
();
},
skip:
kIsWeb
);
// https://github.com/flutter/flutter/issues/87442
test
(
'
$BoxPainter
dispatches memory events'
,
()
async
{
await
expectLater
(
await
memoryEvents
(()
=>
_BoxPainter
().
dispose
(),
_BoxPainter
),
areCreateAndDispose
,
);
});
}
class
_BoxPainter
extends
BoxPainter
{
@override
void
paint
(
Canvas
canvas
,
Offset
offset
,
ImageConfiguration
configuration
)
{}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment