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
3fc364cf
Unverified
Commit
3fc364cf
authored
Jun 11, 2020
by
zmtzawqlp
Committed by
GitHub
Jun 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing arguments for all constructors of ListView and GridView (#58746)
parent
d25b9c80
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
594 additions
and
12 deletions
+594
-12
scroll_view.dart
packages/flutter/lib/src/widgets/scroll_view.dart
+22
-0
scroll_view_test.dart
packages/flutter/test/widgets/scroll_view_test.dart
+572
-12
No files found.
packages/flutter/lib/src/widgets/scroll_view.dart
View file @
3fc364cf
...
...
@@ -1087,6 +1087,7 @@ class ListView extends BoxScrollView {
double
cacheExtent
,
int
semanticChildCount
,
DragStartBehavior
dragStartBehavior
=
DragStartBehavior
.
start
,
ScrollViewKeyboardDismissBehavior
keyboardDismissBehavior
=
ScrollViewKeyboardDismissBehavior
.
manual
,
})
:
assert
(
itemCount
==
null
||
itemCount
>=
0
),
assert
(
semanticChildCount
==
null
||
semanticChildCount
<=
itemCount
),
childrenDelegate
=
SliverChildBuilderDelegate
(
...
...
@@ -1108,6 +1109,7 @@ class ListView extends BoxScrollView {
cacheExtent:
cacheExtent
,
semanticChildCount:
semanticChildCount
??
itemCount
,
dragStartBehavior:
dragStartBehavior
,
keyboardDismissBehavior:
keyboardDismissBehavior
,
);
/// Creates a fixed-length scrollable linear array of list "items" separated
...
...
@@ -1173,6 +1175,7 @@ class ListView extends BoxScrollView {
bool
addRepaintBoundaries
=
true
,
bool
addSemanticIndexes
=
true
,
double
cacheExtent
,
DragStartBehavior
dragStartBehavior
=
DragStartBehavior
.
start
,
ScrollViewKeyboardDismissBehavior
keyboardDismissBehavior
=
ScrollViewKeyboardDismissBehavior
.
manual
,
})
:
assert
(
itemBuilder
!=
null
),
assert
(
separatorBuilder
!=
null
),
...
...
@@ -1214,6 +1217,7 @@ class ListView extends BoxScrollView {
padding:
padding
,
cacheExtent:
cacheExtent
,
semanticChildCount:
itemCount
,
dragStartBehavior:
dragStartBehavior
,
keyboardDismissBehavior:
keyboardDismissBehavior
,
);
...
...
@@ -1312,6 +1316,8 @@ class ListView extends BoxScrollView {
@required
this
.
childrenDelegate
,
double
cacheExtent
,
int
semanticChildCount
,
DragStartBehavior
dragStartBehavior
=
DragStartBehavior
.
start
,
ScrollViewKeyboardDismissBehavior
keyboardDismissBehavior
=
ScrollViewKeyboardDismissBehavior
.
manual
,
})
:
assert
(
childrenDelegate
!=
null
),
super
(
key:
key
,
...
...
@@ -1324,6 +1330,8 @@ class ListView extends BoxScrollView {
padding:
padding
,
cacheExtent:
cacheExtent
,
semanticChildCount:
semanticChildCount
,
dragStartBehavior:
dragStartBehavior
,
keyboardDismissBehavior:
keyboardDismissBehavior
,
);
/// If non-null, forces the children to have the given extent in the scroll
...
...
@@ -1583,6 +1591,8 @@ class GridView extends BoxScrollView {
double
cacheExtent
,
List
<
Widget
>
children
=
const
<
Widget
>[],
int
semanticChildCount
,
DragStartBehavior
dragStartBehavior
=
DragStartBehavior
.
start
,
ScrollViewKeyboardDismissBehavior
keyboardDismissBehavior
=
ScrollViewKeyboardDismissBehavior
.
manual
,
})
:
assert
(
gridDelegate
!=
null
),
childrenDelegate
=
SliverChildListDelegate
(
children
,
...
...
@@ -1601,6 +1611,8 @@ class GridView extends BoxScrollView {
padding:
padding
,
cacheExtent:
cacheExtent
,
semanticChildCount:
semanticChildCount
??
children
.
length
,
dragStartBehavior:
dragStartBehavior
,
keyboardDismissBehavior:
keyboardDismissBehavior
,
);
/// Creates a scrollable, 2D array of widgets that are created on demand.
...
...
@@ -1639,6 +1651,8 @@ class GridView extends BoxScrollView {
bool
addSemanticIndexes
=
true
,
double
cacheExtent
,
int
semanticChildCount
,
DragStartBehavior
dragStartBehavior
=
DragStartBehavior
.
start
,
ScrollViewKeyboardDismissBehavior
keyboardDismissBehavior
=
ScrollViewKeyboardDismissBehavior
.
manual
,
})
:
assert
(
gridDelegate
!=
null
),
childrenDelegate
=
SliverChildBuilderDelegate
(
itemBuilder
,
...
...
@@ -1658,6 +1672,8 @@ class GridView extends BoxScrollView {
padding:
padding
,
cacheExtent:
cacheExtent
,
semanticChildCount:
semanticChildCount
??
itemCount
,
dragStartBehavior:
dragStartBehavior
,
keyboardDismissBehavior:
keyboardDismissBehavior
,
);
/// Creates a scrollable, 2D array of widgets with both a custom
...
...
@@ -1681,6 +1697,7 @@ class GridView extends BoxScrollView {
double
cacheExtent
,
int
semanticChildCount
,
DragStartBehavior
dragStartBehavior
=
DragStartBehavior
.
start
,
ScrollViewKeyboardDismissBehavior
keyboardDismissBehavior
=
ScrollViewKeyboardDismissBehavior
.
manual
,
})
:
assert
(
gridDelegate
!=
null
),
assert
(
childrenDelegate
!=
null
),
super
(
...
...
@@ -1695,6 +1712,7 @@ class GridView extends BoxScrollView {
cacheExtent:
cacheExtent
,
semanticChildCount:
semanticChildCount
,
dragStartBehavior:
dragStartBehavior
,
keyboardDismissBehavior:
keyboardDismissBehavior
,
);
/// Creates a scrollable, 2D array of widgets with a fixed number of tiles in
...
...
@@ -1731,6 +1749,7 @@ class GridView extends BoxScrollView {
List
<
Widget
>
children
=
const
<
Widget
>[],
int
semanticChildCount
,
DragStartBehavior
dragStartBehavior
=
DragStartBehavior
.
start
,
ScrollViewKeyboardDismissBehavior
keyboardDismissBehavior
=
ScrollViewKeyboardDismissBehavior
.
manual
,
})
:
gridDelegate
=
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
crossAxisCount
,
mainAxisSpacing:
mainAxisSpacing
,
...
...
@@ -1755,6 +1774,7 @@ class GridView extends BoxScrollView {
cacheExtent:
cacheExtent
,
semanticChildCount:
semanticChildCount
??
children
.
length
,
dragStartBehavior:
dragStartBehavior
,
keyboardDismissBehavior:
keyboardDismissBehavior
,
);
/// Creates a scrollable, 2D array of widgets with tiles that each have a
...
...
@@ -1790,6 +1810,7 @@ class GridView extends BoxScrollView {
List
<
Widget
>
children
=
const
<
Widget
>[],
int
semanticChildCount
,
DragStartBehavior
dragStartBehavior
=
DragStartBehavior
.
start
,
ScrollViewKeyboardDismissBehavior
keyboardDismissBehavior
=
ScrollViewKeyboardDismissBehavior
.
manual
,
})
:
gridDelegate
=
SliverGridDelegateWithMaxCrossAxisExtent
(
maxCrossAxisExtent:
maxCrossAxisExtent
,
mainAxisSpacing:
mainAxisSpacing
,
...
...
@@ -1813,6 +1834,7 @@ class GridView extends BoxScrollView {
padding:
padding
,
semanticChildCount:
semanticChildCount
??
children
.
length
,
dragStartBehavior:
dragStartBehavior
,
keyboardDismissBehavior:
keyboardDismissBehavior
,
);
/// A delegate that controls the layout of the children within the [GridView].
...
...
packages/flutter/test/widgets/scroll_view_test.dart
View file @
3fc364cf
...
...
@@ -103,22 +103,303 @@ void main() {
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
ListView
(
padding:
const
EdgeInsets
.
all
(
0
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
children:
focusNodes
.
map
((
FocusNode
focusNode
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
child:
ListView
(
padding:
const
EdgeInsets
.
all
(
0
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
children:
focusNodes
.
map
((
FocusNode
focusNode
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNode
,
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)),
);
}).
toList
(),
)));
)
),
);
}).
toList
(),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
});
testWidgets
(
'ListView.builder dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
ListView
.
builder
(
padding:
const
EdgeInsets
.
all
(
0
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
itemCount:
focusNodes
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
},
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
});
testWidgets
(
'ListView.custom dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
ListView
.
custom
(
padding:
const
EdgeInsets
.
all
(
0
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
childrenDelegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
},
childCount:
focusNodes
.
length
,
),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
});
testWidgets
(
'ListView.separated dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
ListView
.
separated
(
padding:
const
EdgeInsets
.
all
(
0
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
itemCount:
focusNodes
.
length
,
separatorBuilder:
(
BuildContext
context
,
int
index
)
=>
const
Divider
(),
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
},
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
});
testWidgets
(
'GridView dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
(
padding:
const
EdgeInsets
.
all
(
0
),
gridDelegate:
const
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
2
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
children:
focusNodes
.
map
((
FocusNode
focusNode
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNode
,
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
}).
toList
(),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
});
testWidgets
(
'GridView.builder dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
.
builder
(
padding:
const
EdgeInsets
.
all
(
0
),
gridDelegate:
const
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
2
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
itemCount:
focusNodes
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
){
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
),
),
);
},
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
});
testWidgets
(
'GridView.count dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
.
count
(
padding:
const
EdgeInsets
.
all
(
0
),
crossAxisCount:
2
,
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
children:
focusNodes
.
map
((
FocusNode
focusNode
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNode
,
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
}).
toList
(),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
});
testWidgets
(
'GridView.extent dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
.
extent
(
padding:
const
EdgeInsets
.
all
(
0
),
maxCrossAxisExtent:
300
,
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
children:
focusNodes
.
map
((
FocusNode
focusNode
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNode
,
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
}).
toList
(),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
});
testWidgets
(
'GridView.custom dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
.
custom
(
padding:
const
EdgeInsets
.
all
(
0
),
gridDelegate:
const
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
2
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
onDrag
,
childrenDelegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
},
childCount:
focusNodes
.
length
,
),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
...
...
@@ -161,6 +442,285 @@ void main() {
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
});
testWidgets
(
'ListView.builder dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
ListView
.
builder
(
padding:
const
EdgeInsets
.
all
(
0
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
manual
,
itemCount:
focusNodes
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
},
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
});
testWidgets
(
'ListView.custom dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
ListView
.
custom
(
padding:
const
EdgeInsets
.
all
(
0
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
manual
,
childrenDelegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
},
childCount:
focusNodes
.
length
,
),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
});
testWidgets
(
'ListView.separated dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
ListView
.
separated
(
padding:
const
EdgeInsets
.
all
(
0
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
manual
,
itemCount:
focusNodes
.
length
,
separatorBuilder:
(
BuildContext
context
,
int
index
)
=>
const
Divider
(),
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
},
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
});
testWidgets
(
'GridView dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
(
padding:
const
EdgeInsets
.
all
(
0
),
gridDelegate:
const
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
2
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
manual
,
children:
focusNodes
.
map
((
FocusNode
focusNode
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNode
,
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
}).
toList
(),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
});
testWidgets
(
'GridView.builder dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
.
builder
(
padding:
const
EdgeInsets
.
all
(
0
),
gridDelegate:
const
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
2
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
manual
,
itemCount:
focusNodes
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
){
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
),
),
);
},
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
});
testWidgets
(
'GridView.count dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
.
count
(
padding:
const
EdgeInsets
.
all
(
0
),
crossAxisCount:
2
,
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
manual
,
children:
focusNodes
.
map
((
FocusNode
focusNode
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNode
,
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
}).
toList
(),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
});
testWidgets
(
'GridView.extent dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
.
extent
(
padding:
const
EdgeInsets
.
all
(
0
),
maxCrossAxisExtent:
300
,
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
manual
,
children:
focusNodes
.
map
((
FocusNode
focusNode
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNode
,
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
}).
toList
(),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
});
testWidgets
(
'GridView.custom dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
final
List
<
FocusNode
>
focusNodes
=
List
<
FocusNode
>.
generate
(
50
,
(
int
i
)
=>
FocusNode
());
await
tester
.
pumpWidget
(
textFieldBoilerplate
(
child:
GridView
.
custom
(
padding:
const
EdgeInsets
.
all
(
0
),
gridDelegate:
const
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
2
),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior
.
manual
,
childrenDelegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
Container
(
height:
50
,
color:
Colors
.
green
,
child:
TextField
(
focusNode:
focusNodes
[
index
],
style:
const
TextStyle
(
fontSize:
24
,
fontWeight:
FontWeight
.
bold
,
)
),
);
},
childCount:
focusNodes
.
length
,
),
),
));
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
});
testWidgets
(
'ListView restart ballistic activity out of range'
,
(
WidgetTester
tester
)
async
{
Widget
buildListView
(
int
n
)
{
return
Directionality
(
...
...
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