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
50ecd570
Unverified
Commit
50ecd570
authored
Oct 28, 2023
by
Kostia Sokolovskyi
Committed by
GitHub
Oct 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BannerPainter should dispatch creation and disposal events. (#137472)
parent
a4ec6278
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
banner.dart
packages/flutter/lib/src/widgets/banner.dart
+18
-1
banner_test.dart
packages/flutter/test/widgets/banner_test.dart
+15
-0
No files found.
packages/flutter/lib/src/widgets/banner.dart
View file @
50ecd570
...
...
@@ -23,6 +23,8 @@ const TextStyle _kTextStyle = TextStyle(
height:
1.0
,
);
const
String
_flutterWidgetsLibrary
=
'package:flutter/widgets.dart'
;
/// Where to show a [Banner].
///
/// The start and end locations are relative to the ambient [Directionality]
...
...
@@ -61,7 +63,17 @@ class BannerPainter extends CustomPainter {
required
this
.
layoutDirection
,
this
.
color
=
_kColor
,
this
.
textStyle
=
_kTextStyle
,
})
:
super
(
repaint:
PaintingBinding
.
instance
.
systemFonts
);
})
:
super
(
repaint:
PaintingBinding
.
instance
.
systemFonts
)
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectCreated
(
library
:
_flutterWidgetsLibrary
,
className:
'
$BannerPainter
'
,
object:
this
,
);
}
}
/// The message to show in the banner.
final
String
message
;
...
...
@@ -117,6 +129,11 @@ class BannerPainter extends CustomPainter {
///
/// After calling this method, this object is no longer usable.
void
dispose
()
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectDisposed
(
object:
this
);
}
_textPainter
?.
dispose
();
_textPainter
=
null
;
}
...
...
packages/flutter/test/widgets/banner_test.dart
View file @
50ecd570
...
...
@@ -280,4 +280,19 @@ void main() {
);
debugDisableShadows
=
true
;
});
test
(
'BannerPainter dispatches memory events'
,
()
async
{
await
expectLater
(
await
memoryEvents
(
()
=>
BannerPainter
(
message:
'foo'
,
textDirection:
TextDirection
.
rtl
,
location:
BannerLocation
.
topStart
,
layoutDirection:
TextDirection
.
ltr
,
).
dispose
(),
BannerPainter
,
),
areCreateAndDispose
,
);
});
}
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