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
7d17c539
Unverified
Commit
7d17c539
authored
May 29, 2020
by
Justin McCandless
Committed by
GitHub
May 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Helpful assertion for isAlwaysShown error (#58258)
parent
6d8ec350
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
4 deletions
+106
-4
scrollbar.dart
packages/flutter/lib/src/cupertino/scrollbar.dart
+2
-2
scrollbar.dart
packages/flutter/lib/src/material/scrollbar.dart
+2
-2
scrollbar_test.dart
packages/flutter/test/cupertino/scrollbar_test.dart
+52
-0
scrollbar_test.dart
packages/flutter/test/material/scrollbar_test.dart
+50
-0
No files found.
packages/flutter/lib/src/cupertino/scrollbar.dart
View file @
7d17c539
...
...
@@ -62,7 +62,8 @@ class CupertinoScrollbar extends StatefulWidget {
this
.
controller
,
this
.
isAlwaysShown
=
false
,
@required
this
.
child
,
})
:
super
(
key:
key
);
})
:
assert
(!
isAlwaysShown
||
controller
!=
null
,
'When isAlwaysShown is true, must pass a controller that is attached to a scroll view'
),
super
(
key:
key
);
/// The subtree to place inside the [CupertinoScrollbar].
///
...
...
@@ -276,7 +277,6 @@ class _CupertinoScrollbarState extends State<CupertinoScrollbar> with TickerProv
void
_triggerScrollbar
()
{
WidgetsBinding
.
instance
.
addPostFrameCallback
((
Duration
duration
)
{
if
(
widget
.
isAlwaysShown
)
{
assert
(
widget
.
controller
!=
null
);
_fadeoutTimer
?.
cancel
();
widget
.
controller
.
position
.
didUpdateScrollPositionBy
(
0
);
}
...
...
packages/flutter/lib/src/material/scrollbar.dart
View file @
7d17c539
...
...
@@ -38,7 +38,8 @@ class Scrollbar extends StatefulWidget {
@required
this
.
child
,
this
.
controller
,
this
.
isAlwaysShown
=
false
,
})
:
super
(
key:
key
);
})
:
assert
(!
isAlwaysShown
||
controller
!=
null
,
'When isAlwaysShown is true, must pass a controller that is attached to a scroll view'
),
super
(
key:
key
);
/// The widget below this widget in the tree.
///
...
...
@@ -131,7 +132,6 @@ class _ScrollbarState extends State<Scrollbar> with TickerProviderStateMixin {
void
_triggerScrollbar
()
{
WidgetsBinding
.
instance
.
addPostFrameCallback
((
Duration
duration
)
{
if
(
widget
.
isAlwaysShown
)
{
assert
(
widget
.
controller
!=
null
);
_fadeoutTimer
?.
cancel
();
widget
.
controller
.
position
.
didUpdateScrollPositionBy
(
0
);
}
...
...
packages/flutter/test/cupertino/scrollbar_test.dart
View file @
7d17c539
...
...
@@ -164,6 +164,58 @@ void main() {
await
tester
.
pump
(
_kScrollbarFadeDuration
);
});
testWidgets
(
'When isAlwaysShown is true, must pass a controller'
,
(
WidgetTester
tester
)
async
{
Widget
viewWithScroll
()
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
CupertinoScrollbar
(
isAlwaysShown:
true
,
child:
const
SingleChildScrollView
(
child:
SizedBox
(
width:
4000.0
,
height:
4000.0
,
),
),
),
),
);
}
expect
(()
async
{
await
tester
.
pumpWidget
(
viewWithScroll
());
},
throwsAssertionError
);
});
testWidgets
(
'When isAlwaysShown is true, must pass a controller that is attached to a scroll view'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
controller
=
ScrollController
();
Widget
viewWithScroll
()
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
CupertinoScrollbar
(
controller:
controller
,
isAlwaysShown:
true
,
child:
const
SingleChildScrollView
(
child:
SizedBox
(
width:
4000.0
,
height:
4000.0
,
),
),
),
),
);
}
await
tester
.
pumpWidget
(
viewWithScroll
());
final
dynamic
exception
=
tester
.
takeException
();
expect
(
exception
,
isAssertionError
);
});
testWidgets
(
'On first render with isAlwaysShown: true, the thumb shows'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
controller
=
ScrollController
();
...
...
packages/flutter/test/material/scrollbar_test.dart
View file @
7d17c539
...
...
@@ -201,6 +201,56 @@ void main() {
expect
(
scrollbar
.
controller
,
isNotNull
);
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
testWidgets
(
'When isAlwaysShown is true, must pass a controller'
,
(
WidgetTester
tester
)
async
{
Widget
viewWithScroll
()
{
return
_buildBoilerplate
(
child:
Theme
(
data:
ThemeData
(),
child:
Scrollbar
(
isAlwaysShown:
true
,
child:
const
SingleChildScrollView
(
child:
SizedBox
(
width:
4000.0
,
height:
4000.0
,
),
),
),
),
);
}
expect
(()
async
{
await
tester
.
pumpWidget
(
viewWithScroll
());
},
throwsAssertionError
);
});
testWidgets
(
'When isAlwaysShown is true, must pass a controller that is attached to a scroll view'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
controller
=
ScrollController
();
Widget
viewWithScroll
()
{
return
_buildBoilerplate
(
child:
Theme
(
data:
ThemeData
(),
child:
Scrollbar
(
isAlwaysShown:
true
,
controller:
controller
,
child:
const
SingleChildScrollView
(
child:
SizedBox
(
width:
4000.0
,
height:
4000.0
,
),
),
),
),
);
}
await
tester
.
pumpWidget
(
viewWithScroll
());
final
dynamic
exception
=
tester
.
takeException
();
expect
(
exception
,
isAssertionError
);
});
testWidgets
(
'On first render with isAlwaysShown: true, the thumb shows'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
controller
=
ScrollController
();
...
...
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