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
df259c58
Unverified
Commit
df259c58
authored
Oct 25, 2022
by
Taha Tesser
Committed by
GitHub
Oct 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `clipBehavior` and apply `borderRadius` to DataTable's Material (#113205)
parent
9f5c6553
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
0 deletions
+62
-0
data_table.dart
packages/flutter/lib/src/material/data_table.dart
+11
-0
table_border.dart
packages/flutter/lib/src/rendering/table_border.dart
+2
-0
data_table_test.dart
packages/flutter/test/material/data_table_test.dart
+49
-0
No files found.
packages/flutter/lib/src/material/data_table.dart
View file @
df259c58
...
...
@@ -406,6 +406,7 @@ class DataTable extends StatelessWidget {
required
this
.
rows
,
this
.
checkboxHorizontalMargin
,
this
.
border
,
this
.
clipBehavior
=
Clip
.
none
,
})
:
assert
(
columns
!=
null
),
assert
(
columns
.
isNotEmpty
),
assert
(
sortColumnIndex
==
null
||
(
sortColumnIndex
>=
0
&&
sortColumnIndex
<
columns
.
length
)),
...
...
@@ -414,6 +415,7 @@ class DataTable extends StatelessWidget {
assert
(
rows
!=
null
),
assert
(!
rows
.
any
((
DataRow
row
)
=>
row
.
cells
.
length
!=
columns
.
length
)),
assert
(
dividerThickness
==
null
||
dividerThickness
>=
0
),
assert
(
clipBehavior
!=
null
),
_onlyTextColumn
=
_initOnlyTextColumn
(
columns
);
/// The configuration and labels for the columns in the table.
...
...
@@ -638,6 +640,13 @@ class DataTable extends StatelessWidget {
/// The style to use when painting the boundary and interior divisions of the table.
final
TableBorder
?
border
;
/// {@macro flutter.material.Material.clipBehavior}
///
/// This can be used to clip the content within the border of the [DataTable].
///
/// Defaults to [Clip.none], and must not be null.
final
Clip
clipBehavior
;
// 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
;
...
...
@@ -1056,6 +1065,8 @@ class DataTable extends StatelessWidget {
decoration:
decoration
??
dataTableTheme
.
decoration
??
theme
.
dataTableTheme
.
decoration
,
child:
Material
(
type:
MaterialType
.
transparency
,
borderRadius:
border
?.
borderRadius
,
clipBehavior:
clipBehavior
,
child:
Table
(
columnWidths:
tableColumns
.
asMap
(),
children:
tableRows
,
...
...
packages/flutter/lib/src/rendering/table_border.dart
View file @
df259c58
...
...
@@ -74,6 +74,8 @@ class TableBorder {
final
BorderSide
verticalInside
;
/// The [BorderRadius] to use when painting the corners of this border.
///
/// It is also applied to [DataTable]'s [Material].
final
BorderRadius
borderRadius
;
/// The widths of the sides of this border represented as an [EdgeInsets].
...
...
packages/flutter/test/material/data_table_test.dart
View file @
df259c58
...
...
@@ -1895,4 +1895,53 @@ void main() {
// Go without crashes.
});
testWidgets
(
'DataTable clip behavior'
,
(
WidgetTester
tester
)
async
{
const
Color
selectedColor
=
Colors
.
green
;
const
Color
defaultColor
=
Colors
.
red
;
const
BorderRadius
borderRadius
=
BorderRadius
.
all
(
Radius
.
circular
(
30
));
Widget
buildTable
({
bool
selected
=
false
,
required
Clip
clipBehavior
})
{
return
Material
(
child:
DataTable
(
clipBehavior:
clipBehavior
,
border:
TableBorder
.
all
(
borderRadius:
borderRadius
),
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Column1'
),
),
],
rows:
<
DataRow
>[
DataRow
(
selected:
selected
,
color:
MaterialStateProperty
.
resolveWith
<
Color
>(
(
Set
<
MaterialState
>
states
)
{
if
(
states
.
contains
(
MaterialState
.
selected
))
{
return
selectedColor
;
}
return
defaultColor
;
},
),
cells:
const
<
DataCell
>[
DataCell
(
Text
(
'Content1'
)),
],
),
],
),
);
}
// Test default clip behavior.
await
tester
.
pumpWidget
(
MaterialApp
(
home:
buildTable
(
clipBehavior:
Clip
.
none
)));
Material
material
=
tester
.
widget
<
Material
>(
find
.
byType
(
Material
).
last
);
expect
(
material
.
clipBehavior
,
Clip
.
none
);
expect
(
material
.
borderRadius
,
borderRadius
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
buildTable
(
clipBehavior:
Clip
.
hardEdge
)));
material
=
tester
.
widget
<
Material
>(
find
.
byType
(
Material
).
last
);
expect
(
material
.
clipBehavior
,
Clip
.
hardEdge
);
expect
(
material
.
borderRadius
,
borderRadius
);
});
}
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