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
d907a262
Unverified
Commit
d907a262
authored
Jan 10, 2020
by
Ben Konyi
Committed by
GitHub
Jan 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue where PaginatedDataTable would not fill the width of its containing Card (#48531)
parent
31f399f9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
142 additions
and
60 deletions
+142
-60
paginated_data_table.dart
packages/flutter/lib/src/material/paginated_data_table.dart
+67
-60
paginated_data_table_test.dart
...ages/flutter/test/material/paginated_data_table_test.dart
+75
-0
No files found.
packages/flutter/lib/src/material/paginated_data_table.dart
View file @
d907a262
...
...
@@ -426,6 +426,8 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
]);
// CARD
return
LayoutBuilder
(
builder:
(
BuildContext
context
,
BoxConstraints
constraints
)
{
return
Card
(
semanticContainer:
false
,
child:
Column
(
...
...
@@ -460,6 +462,8 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
SingleChildScrollView
(
scrollDirection:
Axis
.
horizontal
,
dragStartBehavior:
widget
.
dragStartBehavior
,
child:
ConstrainedBox
(
constraints:
BoxConstraints
(
minWidth:
constraints
.
minWidth
),
child:
DataTable
(
key:
_tableKey
,
columns:
widget
.
columns
,
...
...
@@ -470,10 +474,10 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
headingRowHeight:
widget
.
headingRowHeight
,
horizontalMargin:
widget
.
horizontalMargin
,
columnSpacing:
widget
.
columnSpacing
,
showCheckboxColumn:
widget
.
showCheckboxColumn
,
rows:
_getRows
(
_firstRowIndex
,
widget
.
rowsPerPage
),
),
),
),
DefaultTextStyle
(
style:
footerTextStyle
,
child:
IconTheme
.
merge
(
...
...
@@ -481,6 +485,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
opacity:
0.54
),
child:
Container
(
// TODO(bkonyi): this won't handle text zoom correctly, https://github.com/flutter/flutter/issues/48522
height:
56.0
,
child:
SingleChildScrollView
(
dragStartBehavior:
widget
.
dragStartBehavior
,
...
...
@@ -496,5 +501,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
],
),
);
},
);
}
}
packages/flutter/test/material/paginated_data_table_test.dart
View file @
d907a262
...
...
@@ -50,6 +50,9 @@ class TestDataSource extends DataTableSource {
}
void
main
(
)
{
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
()
as
TestWidgetsFlutterBinding
;
testWidgets
(
'PaginatedDataTable paging'
,
(
WidgetTester
tester
)
async
{
final
TestDataSource
source
=
TestDataSource
();
...
...
@@ -382,6 +385,16 @@ void main() {
const
double
_defaultColumnSpacing
=
56.0
;
const
double
_customHorizontalMargin
=
10.0
;
const
double
_customColumnSpacing
=
15.0
;
const
double
_width
=
400
;
const
double
_height
=
400
;
final
Size
originalSize
=
binding
.
renderView
.
size
;
// Ensure the containing Card is small enough that we don't expand too
// much, resulting in our custom margin being ignored.
await
binding
.
setSurfaceSize
(
const
Size
(
_width
,
_height
));
final
TestDataSource
source
=
TestDataSource
(
onSelectChanged:
(
bool
value
)
{},
);
...
...
@@ -527,6 +540,9 @@ void main() {
tester
.
getRect
(
padding
).
right
-
tester
.
getRect
(
cellContent
).
right
,
_customHorizontalMargin
,
);
// Reset the surface size.
await
binding
.
setSurfaceSize
(
originalSize
);
});
testWidgets
(
'PaginatedDataTable custom horizontal padding - no checkbox'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -651,4 +667,63 @@ void main() {
_customHorizontalMargin
,
);
});
testWidgets
(
'PaginatedDataTable table fills Card width'
,
(
WidgetTester
tester
)
async
{
final
TestDataSource
source
=
TestDataSource
();
// Note: 800 is wide enough to ensure that all of the columns fit in the
// Card. The DataTable can be larger than its containing Card, but this test
// is only concerned with ensuring the DataTable is at least as wide as the
// Card.
const
double
_originalWidth
=
800
;
const
double
_expandedWidth
=
1600
;
const
double
_height
=
400
;
final
Size
originalSize
=
binding
.
renderView
.
size
;
Widget
buildWidget
()
=>
MaterialApp
(
home:
PaginatedDataTable
(
header:
const
Text
(
'Test table'
),
source
:
source
,
rowsPerPage:
2
,
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
DataColumn
(
label:
Text
(
'Calories'
),
numeric:
true
),
DataColumn
(
label:
Text
(
'Generation'
)),
],
),
);
await
binding
.
setSurfaceSize
(
const
Size
(
_originalWidth
,
_height
));
await
tester
.
pumpWidget
(
buildWidget
());
// Widths should be equal before we resize...
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byType
(
DataTable
).
first
).
size
.
width
,
moreOrLessEquals
(
tester
.
renderObject
<
RenderBox
>(
find
.
byType
(
Card
).
first
).
size
.
width
)
);
await
binding
.
setSurfaceSize
(
const
Size
(
_expandedWidth
,
_height
));
await
tester
.
pumpWidget
(
buildWidget
());
final
double
cardWidth
=
tester
.
renderObject
<
RenderBox
>(
find
.
byType
(
Card
).
first
).
size
.
width
;
// ... and should still be equal after the resize.
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byType
(
DataTable
).
first
).
size
.
width
,
moreOrLessEquals
(
cardWidth
)
);
// Double check to ensure we actually resized the surface properly.
expect
(
cardWidth
,
moreOrLessEquals
(
_expandedWidth
));
// Reset the surface size.
await
binding
.
setSurfaceSize
(
originalSize
);
});
}
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