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
b3d1ebf1
Unverified
Commit
b3d1ebf1
authored
Sep 11, 2020
by
Ian Hickson
Committed by
GitHub
Sep 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the registration of the restoration channel to binding initialization. (#65579)
parent
2c27fdbb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
restoration.dart
packages/flutter/lib/src/services/restoration.dart
+19
-3
channel_buffers_test.dart
packages/flutter/test/services/channel_buffers_test.dart
+1
-2
restoration.dart
packages/flutter/test/services/restoration.dart
+10
-0
No files found.
packages/flutter/lib/src/services/restoration.dart
View file @
b3d1ebf1
...
...
@@ -97,6 +97,25 @@ typedef _BucketVisitor = void Function(RestorationBucket bucket);
/// * [RestorationMixin], which uses [RestorationBucket]s behind the scenes
/// to make [State] objects of [StatefulWidget]s restorable.
class
RestorationManager
extends
ChangeNotifier
{
/// Construct the restoration manager and set up the communications channels
/// with the engine to get restoration messages (by calling [initChannels]).
RestorationManager
()
{
initChannels
();
}
/// Sets up the method call handler for [SystemChannels.restoration].
///
/// This is called by the constructor to configure the communications channel
/// with the Flutter engine to get restoration messages.
///
/// Subclasses (especially in tests) can override this to avoid setting up
/// that communications channel, or to set it up differently, as necessary.
@protected
void
initChannels
()
{
assert
(!
SystemChannels
.
restoration
.
checkMethodCallHandler
(
_methodHandler
));
SystemChannels
.
restoration
.
setMethodCallHandler
(
_methodHandler
);
}
/// The root of the [RestorationBucket] hierarchy containing the restoration
/// data.
///
...
...
@@ -128,9 +147,6 @@ class RestorationManager extends ChangeNotifier {
/// * [RootRestorationScope], which makes the root bucket available in the
/// [Widget] tree.
Future
<
RestorationBucket
?>
get
rootBucket
{
if
(!
SystemChannels
.
restoration
.
checkMethodCallHandler
(
_methodHandler
))
{
SystemChannels
.
restoration
.
setMethodCallHandler
(
_methodHandler
);
}
if
(
_rootBucketIsValid
)
{
return
SynchronousFuture
<
RestorationBucket
?>(
_rootBucket
);
}
...
...
packages/flutter/test/services/channel_buffers_test.dart
View file @
b3d1ebf1
...
...
@@ -15,8 +15,7 @@ import 'package:flutter/scheduler.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
class
TestChannelBuffersFlutterBinding
extends
BindingBase
with
SchedulerBinding
,
ServicesBinding
{
}
class
TestChannelBuffersFlutterBinding
extends
BindingBase
with
SchedulerBinding
,
ServicesBinding
{
}
void
main
(
)
{
ByteData
_makeByteData
(
String
str
)
{
...
...
packages/flutter/test/services/restoration.dart
View file @
b3d1ebf1
...
...
@@ -10,11 +10,21 @@ import 'package:flutter/services.dart';
import
'package:flutter_test/flutter_test.dart'
;
class
MockRestorationManager
extends
TestRestorationManager
{
MockRestorationManager
({
this
.
enableChannels
=
false
});
bool
get
updateScheduled
=>
_updateScheduled
;
bool
_updateScheduled
=
false
;
final
List
<
RestorationBucket
>
_buckets
=
<
RestorationBucket
>[];
final
bool
enableChannels
;
@override
void
initChannels
()
{
if
(
enableChannels
)
super
.
initChannels
();
}
@override
void
scheduleSerializationFor
(
RestorationBucket
bucket
)
{
_updateScheduled
=
true
;
...
...
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