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
c0b21b16
Unverified
Commit
c0b21b16
authored
Nov 06, 2023
by
Kostia Sokolovskyi
Committed by
GitHub
Nov 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SemanticsHandle should dispatch creation and disposal events. (#137960)
parent
4880aab1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
1 deletion
+43
-1
object.dart
packages/flutter/lib/src/rendering/object.dart
+16
-0
binding.dart
packages/flutter/lib/src/semantics/binding.dart
+17
-1
semantics_binding_test.dart
packages/flutter/test/semantics/semantics_binding_test.dart
+10
-0
No files found.
packages/flutter/lib/src/rendering/object.dart
View file @
c0b21b16
...
...
@@ -822,6 +822,16 @@ typedef LayoutCallback<T extends Constraints> = void Function(T constraints);
class
_LocalSemanticsHandle
implements
SemanticsHandle
{
_LocalSemanticsHandle
.
_
(
PipelineOwner
owner
,
this
.
listener
)
:
_owner
=
owner
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectCreated
(
library
:
'package:flutter/rendering.dart'
,
className:
'
$_LocalSemanticsHandle
'
,
object:
this
,
);
}
if
(
listener
!=
null
)
{
_owner
.
semanticsOwner
!.
addListener
(
listener
!);
}
...
...
@@ -834,6 +844,12 @@ class _LocalSemanticsHandle implements SemanticsHandle {
@override
void
dispose
()
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectDisposed
(
object:
this
);
}
if
(
listener
!=
null
)
{
_owner
.
semanticsOwner
!.
removeListener
(
listener
!);
}
...
...
packages/flutter/lib/src/semantics/binding.dart
View file @
c0b21b16
...
...
@@ -191,7 +191,17 @@ mixin SemanticsBinding on BindingBase {
///
/// To obtain a [SemanticsHandle], call [SemanticsBinding.ensureSemantics].
class
SemanticsHandle
{
SemanticsHandle
.
_
(
this
.
_onDispose
);
SemanticsHandle
.
_
(
this
.
_onDispose
)
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectCreated
(
library
:
'package:flutter/semantics.dart'
,
className:
'
$SemanticsHandle
'
,
object:
this
,
);
}
}
final
VoidCallback
_onDispose
;
...
...
@@ -201,6 +211,12 @@ class SemanticsHandle {
/// framework will stop generating semantics information.
@mustCallSuper
void
dispose
()
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectDisposed
(
object:
this
);
}
_onDispose
();
}
}
packages/flutter/test/semantics/semantics_binding_test.dart
View file @
c0b21b16
...
...
@@ -82,4 +82,14 @@ void main() {
expect
(
SemanticsBinding
.
instance
.
semanticsEnabled
,
isFalse
);
expect
(
tester
.
binding
.
pipelineOwner
.
semanticsOwner
,
isNull
);
},
semanticsEnabled:
false
);
test
(
'SemanticsHandle dispatches memory events'
,
()
async
{
await
expectLater
(
await
memoryEvents
(
()
=>
SemanticsBinding
.
instance
.
ensureSemantics
().
dispose
(),
SemanticsHandle
,
),
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