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
8a365886
Commit
8a365886
authored
Mar 13, 2017
by
Hans Muller
Committed by
GitHub
Mar 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed scrollable TabBar flashing (#8741)
parent
71aaa5db
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
76 deletions
+121
-76
tab_controller.dart
packages/flutter/lib/src/material/tab_controller.dart
+1
-0
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+89
-62
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+31
-14
No files found.
packages/flutter/lib/src/material/tab_controller.dart
View file @
8a365886
...
...
@@ -99,6 +99,7 @@ class TabController extends ChangeNotifier {
_index
=
value
;
if
(
duration
!=
null
)
{
_indexIsChangingCount
+=
1
;
notifyListeners
();
// Because the value of indexIsChanging may have changed.
_animationController
..
animateTo
(
_index
.
toDouble
(),
duration:
duration
,
curve:
curve
).
whenComplete
(()
{
_indexIsChangingCount
-=
1
;
...
...
packages/flutter/lib/src/material/tabs.dart
View file @
8a365886
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/tabs_test.dart
View file @
8a365886
...
...
@@ -618,7 +618,7 @@ void main() {
expect
(
secondColor
,
equals
(
Colors
.
blue
[
500
]));
});
testWidgets
(
'TabBar
unselectedLabelColor control
test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'TabBar
View page left and right
test'
,
(
WidgetTester
tester
)
async
{
final
TabController
controller
=
new
TabController
(
vsync:
const
TestVSync
(),
length:
2
,
...
...
@@ -635,29 +635,46 @@ void main() {
expect
(
controller
.
index
,
equals
(
0
));
final
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Point
(
100.0
,
100.0
));
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Point
(
100.0
,
100.0
));
expect
(
controller
.
index
,
equals
(
0
));
await
gesture
.
moveBy
(
const
Offset
(-
380.0
,
0.0
));
// Drag to the left and right, by less than the TabBarView's width.
// The selected index (controller.index) should not change.
await
gesture
.
moveBy
(
const
Offset
(-
100.0
,
0.0
));
await
gesture
.
moveBy
(
const
Offset
(
100.0
,
0.0
));
expect
(
controller
.
index
,
equals
(
0
));
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
expect
(
find
.
text
(
'Second'
),
findsNothing
);
await
gesture
.
moveBy
(
const
Offset
(-
40.0
,
0.0
));
// Drag more than the TabBarView's width to the right. This forces
// the selected index to change to 1.
await
gesture
.
moveBy
(
const
Offset
(-
500.0
,
0.0
));
await
gesture
.
up
();
await
tester
.
pump
();
// start the scroll animation
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the scroll animation
expect
(
controller
.
index
,
equals
(
1
));
expect
(
find
.
text
(
'First'
),
findsNothing
);
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
await
gesture
.
moveBy
(
const
Offset
(-
40.0
,
0.0
));
await
tester
.
pump
();
gesture
=
await
tester
.
startGesture
(
const
Point
(
100.0
,
100.0
));
expect
(
controller
.
index
,
equals
(
1
));
await
gesture
.
up
();
await
tester
.
pumpUntilNoTransientCallbacks
();
// Drag to the left and right, by less than the TabBarView's width.
// The selected index (controller.index) should not change.
await
gesture
.
moveBy
(
const
Offset
(-
100.0
,
0.0
));
await
gesture
.
moveBy
(
const
Offset
(
100.0
,
0.0
));
expect
(
controller
.
index
,
equals
(
1
));
expect
(
find
.
text
(
'First'
),
findsNothing
);
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
});
// Drag more than the TabBarView's width to the left. This forces
// the selected index to change back to 0.
await
gesture
.
moveBy
(
const
Offset
(
500.0
,
0.0
));
await
gesture
.
up
();
await
tester
.
pump
();
// start the scroll animation
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the scroll animation
expect
(
controller
.
index
,
equals
(
0
));
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
expect
(
find
.
text
(
'Second'
),
findsNothing
);
});
}
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