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
109893c6
Unverified
Commit
109893c6
authored
Aug 20, 2019
by
rami-a
Committed by
GitHub
Aug 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Material] Add contentPadding property to SwitchListTile (#38709)
parent
2daab305
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
switch_list_tile.dart
packages/flutter/lib/src/material/switch_list_tile.dart
+12
-0
switch_list_tile_test.dart
packages/flutter/test/material/switch_list_tile_test.dart
+41
-0
No files found.
packages/flutter/lib/src/material/switch_list_tile.dart
View file @
109893c6
...
...
@@ -279,6 +279,7 @@ class SwitchListTile extends StatelessWidget {
this
.
subtitle
,
this
.
isThreeLine
=
false
,
this
.
dense
,
this
.
contentPadding
,
this
.
secondary
,
this
.
selected
=
false
,
})
:
_switchListTileType
=
_SwitchListTileType
.
material
,
...
...
@@ -310,6 +311,7 @@ class SwitchListTile extends StatelessWidget {
this
.
subtitle
,
this
.
isThreeLine
=
false
,
this
.
dense
,
this
.
contentPadding
,
this
.
secondary
,
this
.
selected
=
false
,
})
:
_switchListTileType
=
_SwitchListTileType
.
adaptive
,
...
...
@@ -409,6 +411,15 @@ class SwitchListTile extends StatelessWidget {
/// If this property is null then its value is based on [ListTileTheme.dense].
final
bool
dense
;
/// The tile's internal padding.
///
/// Insets a [SwitchListTile]'s contents: its [title], [subtitle],
/// [secondary], and [Switch] widgets.
///
/// If null, [ListTile]'s default of `EdgeInsets.symmetric(horizontal: 16.0)`
/// is used.
final
EdgeInsetsGeometry
contentPadding
;
/// Whether to render icons and text in the [activeColor].
///
/// No effort is made to automatically coordinate the [selected] state and the
...
...
@@ -462,6 +473,7 @@ class SwitchListTile extends StatelessWidget {
trailing:
control
,
isThreeLine:
isThreeLine
,
dense:
dense
,
contentPadding:
contentPadding
,
enabled:
onChanged
!=
null
,
onTap:
onChanged
!=
null
?
()
{
onChanged
(!
value
);
}
:
null
,
selected:
selected
,
...
...
packages/flutter/test/material/switch_list_tile_test.dart
View file @
109893c6
...
...
@@ -100,4 +100,45 @@ void main() {
await
tester
.
tap
(
find
.
byType
(
SwitchListTile
));
expect
(
value
,
isFalse
);
});
testWidgets
(
'SwitchListTile contentPadding'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
(
TextDirection
textDirection
)
{
return
MediaQuery
(
data:
const
MediaQueryData
(
padding:
EdgeInsets
.
zero
,
textScaleFactor:
1.0
,
),
child:
Directionality
(
textDirection:
textDirection
,
child:
Material
(
child:
Container
(
alignment:
Alignment
.
topLeft
,
child:
SwitchListTile
(
contentPadding:
const
EdgeInsetsDirectional
.
only
(
start:
10.0
,
end:
20.0
,
top:
30.0
,
bottom:
40.0
,
),
secondary:
const
Text
(
'L'
),
title:
const
Text
(
'title'
),
value:
true
,
onChanged:
(
bool
selected
)
{},
),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
TextDirection
.
ltr
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'L'
)).
dx
,
10.0
);
// contentPadding.start = 10
expect
(
tester
.
getTopRight
(
find
.
byType
(
Switch
)).
dx
,
780.0
);
// 800 - contentPadding.end
await
tester
.
pumpWidget
(
buildFrame
(
TextDirection
.
rtl
));
expect
(
tester
.
getTopLeft
(
find
.
byType
(
Switch
)).
dx
,
20.0
);
// contentPadding.end = 20
expect
(
tester
.
getTopRight
(
find
.
text
(
'L'
)).
dx
,
790.0
);
// 800 - contentPadding.start
});
}
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