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
c168afc0
Commit
c168afc0
authored
May 31, 2017
by
xster
Committed by
GitHub
May 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix performance regression with _InheritedTheme (#10311)
Check ThemeData instead of Theme.
parent
ccad2849
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
1 deletion
+69
-1
theme.dart
packages/flutter/lib/src/material/theme.dart
+1
-1
theme_test.dart
packages/flutter/test/material/theme_test.dart
+68
-0
No files found.
packages/flutter/lib/src/material/theme.dart
View file @
c168afc0
...
...
@@ -155,7 +155,7 @@ class _InheritedTheme extends InheritedWidget {
final
Theme
theme
;
@override
bool
updateShouldNotify
(
_InheritedTheme
old
)
=>
theme
!=
old
.
theme
;
bool
updateShouldNotify
(
_InheritedTheme
old
)
=>
theme
.
data
!=
old
.
theme
.
data
;
}
/// An interpolation between two [ThemeData]s.
...
...
packages/flutter/test/material/theme_test.dart
View file @
c168afc0
...
...
@@ -265,4 +265,72 @@ void main() {
expect
(
glyphText
.
text
.
style
.
color
,
Colors
.
orange
);
expect
(
glyphText
.
text
.
style
.
fontSize
,
20.0
);
});
testWidgets
(
'Same ThemeData reapplied does not trigger descendents rebuilds'
,
(
WidgetTester
tester
)
async
{
testBuildCalled
=
0
;
ThemeData
themeData
=
new
ThemeData
(
primaryColor:
const
Color
(
0xFF000000
));
await
tester
.
pumpWidget
(
new
Theme
(
data:
themeData
,
child:
const
Test
(),
),
);
expect
(
testBuildCalled
,
1
);
// Pump the same widgets again.
await
tester
.
pumpWidget
(
new
Theme
(
data:
themeData
,
child:
const
Test
(),
),
);
// No repeated build calls to the child since it's the same theme data.
expect
(
testBuildCalled
,
1
);
// New instance of theme data but still the same content.
themeData
=
new
ThemeData
(
primaryColor:
const
Color
(
0xFF000000
));
await
tester
.
pumpWidget
(
new
Theme
(
data:
themeData
,
child:
const
Test
(),
),
);
// Still no repeated calls.
expect
(
testBuildCalled
,
1
);
// Different now.
themeData
=
new
ThemeData
(
primaryColor:
const
Color
(
0xFF222222
));
await
tester
.
pumpWidget
(
new
Theme
(
data:
themeData
,
child:
const
Test
(),
),
);
// Should call build again.
expect
(
testBuildCalled
,
2
);
},
);
}
int
testBuildCalled
;
class
Test
extends
StatefulWidget
{
const
Test
();
@override
_TestState
createState
()
=>
new
_TestState
();
}
class
_TestState
extends
State
<
Test
>
{
@override
Widget
build
(
BuildContext
context
)
{
testBuildCalled
+=
1
;
return
new
Container
(
decoration:
new
BoxDecoration
(
color:
Theme
.
of
(
context
).
primaryColor
,
),
);
}
}
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