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
88800084
Unverified
Commit
88800084
authored
Nov 01, 2021
by
Dheeraj Verma
Committed by
GitHub
Nov 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Data Table Class with Borders Like Table Widgets (#36837) (#92670)
parent
c97a8622
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
0 deletions
+70
-0
data_table.dart
packages/flutter/lib/src/material/data_table.dart
+5
-0
data_table_test.dart
packages/flutter/test/material/data_table_test.dart
+65
-0
No files found.
packages/flutter/lib/src/material/data_table.dart
View file @
88800084
...
...
@@ -391,6 +391,7 @@ class DataTable extends StatelessWidget {
this
.
dividerThickness
,
required
this
.
rows
,
this
.
checkboxHorizontalMargin
,
this
.
border
,
})
:
assert
(
columns
!=
null
),
assert
(
columns
.
isNotEmpty
),
assert
(
sortColumnIndex
==
null
||
(
sortColumnIndex
>=
0
&&
sortColumnIndex
<
columns
.
length
)),
...
...
@@ -615,6 +616,9 @@ class DataTable extends StatelessWidget {
/// and the content in the first data column. This value defaults to 24.0.
final
double
?
checkboxHorizontalMargin
;
/// The style to use when painting the boundary and interior divisions of the table.
final
TableBorder
?
border
;
// Set by the constructor to the index of the only Column that is
// non-numeric, if there is exactly one, otherwise null.
final
int
?
_onlyTextColumn
;
...
...
@@ -1022,6 +1026,7 @@ class DataTable extends StatelessWidget {
child:
Table
(
columnWidths:
tableColumns
.
asMap
(),
children:
tableRows
,
border:
border
,
),
),
);
...
...
packages/flutter/test/material/data_table_test.dart
View file @
88800084
...
...
@@ -1670,4 +1670,69 @@ void main() {
expect
(
find
.
widgetWithText
(
TableRowInkWell
,
'Bug'
),
findsNothing
);
expect
(
find
.
widgetWithText
(
TableRowInkWell
,
'GitHub'
),
findsNothing
);
});
testWidgets
(
'DataTable set interior border test'
,
(
WidgetTester
tester
)
async
{
const
List
<
DataColumn
>
columns
=
<
DataColumn
>[
DataColumn
(
label:
Text
(
'column1'
)),
DataColumn
(
label:
Text
(
'column2'
)),
];
const
List
<
DataCell
>
cells
=
<
DataCell
>[
DataCell
(
Text
(
'cell1'
)),
DataCell
(
Text
(
'cell2'
)),
];
const
List
<
DataRow
>
rows
=
<
DataRow
>[
DataRow
(
cells:
cells
),
DataRow
(
cells:
cells
),
];
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
DataTable
(
border:
TableBorder
.
all
(
width:
2
,
color:
Colors
.
red
),
columns:
columns
,
rows:
rows
,
),
),
),
);
final
Finder
finder
=
find
.
byType
(
DataTable
);
expect
(
tester
.
getSize
(
finder
),
equals
(
const
Size
(
800
,
600
)));
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
DataTable
(
border:
TableBorder
.
all
(
color:
Colors
.
red
),
columns:
columns
,
rows:
rows
,
),
),
),
);
Table
table
=
tester
.
widget
(
find
.
byType
(
Table
));
TableBorder
?
tableBorder
=
table
.
border
;
expect
(
tableBorder
!.
top
.
color
,
Colors
.
red
);
expect
(
tableBorder
.
bottom
.
width
,
1
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
DataTable
(
columns:
columns
,
rows:
rows
,
),
),
),
);
table
=
tester
.
widget
(
find
.
byType
(
Table
));
tableBorder
=
table
.
border
;
expect
(
tableBorder
?.
bottom
.
width
,
null
);
expect
(
tableBorder
?.
top
.
color
,
null
);
});
}
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