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
248645a2
Unverified
Commit
248645a2
authored
Sep 02, 2023
by
Polina Cherkasova
Committed by
GitHub
Sep 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RestorableProperty should dispatch creation in constructor. (#133883)
parent
a3362a9f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletion
+15
-1
restoration.dart
packages/flutter/lib/src/widgets/restoration.dart
+7
-0
time_test.dart
packages/flutter/test/material/time_test.dart
+3
-1
restorable_property_test.dart
packages/flutter/test/widgets/restorable_property_test.dart
+5
-0
No files found.
packages/flutter/lib/src/widgets/restoration.dart
View file @
248645a2
...
...
@@ -454,6 +454,13 @@ class _RootRestorationScopeState extends State<RootRestorationScope> {
/// * [RestorationManager], which describes how state restoration works in
/// Flutter.
abstract
class
RestorableProperty
<
T
>
extends
ChangeNotifier
{
/// Creates a [RestorableProperty].
RestorableProperty
(){
if
(
kFlutterMemoryAllocationsEnabled
)
{
maybeDispatchObjectCreation
();
}
}
/// Called by the [RestorationMixin] if no restoration data is available to
/// restore the value of the property from to obtain the default value for the
/// property.
...
...
packages/flutter/test/material/time_test.dart
View file @
248645a2
...
...
@@ -58,7 +58,9 @@ void main() {
group
(
'RestorableTimeOfDay tests'
,
()
{
testWidgetsWithLeakTracking
(
'value is not accessible when not registered'
,
(
WidgetTester
tester
)
async
{
expect
(()
=>
RestorableTimeOfDay
(
const
TimeOfDay
(
hour:
20
,
minute:
4
)).
value
,
throwsAssertionError
);
final
RestorableTimeOfDay
property
=
RestorableTimeOfDay
(
const
TimeOfDay
(
hour:
20
,
minute:
4
));
addTearDown
(()
=>
property
.
dispose
());
expect
(()
=>
property
.
value
,
throwsAssertionError
);
});
testWidgets
(
'work when not in restoration scope'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/widgets/restorable_property_test.dart
View file @
248645a2
...
...
@@ -4,6 +4,7 @@
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
void
main
(
)
{
testWidgets
(
'value is not accessible when not registered'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -25,6 +26,10 @@ void main() {
expect
(()
=>
_TestRestorableValue
().
value
,
throwsAssertionError
);
});
testWidgetsWithLeakTracking
(
'
$RestorableProperty
dispatches creation in constructor'
,
(
WidgetTester
widgetTester
)
async
{
expect
(()=>
RestorableDateTimeN
(
null
).
dispose
(),
dispatchesMemoryEvents
(
RestorableDateTimeN
));
});
testWidgets
(
'work when not in restoration scope'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
_RestorableWidget
());
...
...
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