[M3] Add customizable overflow property to Snackbar's action (#120394)
* add actionOverflowThreshold param * analyzer tings * https://www.youtube.com/watch?v=NPwyyjtxlzU * remove erroneous switch changes * rename test * remove unwanted switch.dart diff * remove redundant values * review changes
This commit is contained in:
@@ -43,19 +43,22 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
||||
bool _withAction = true;
|
||||
bool _multiLine = false;
|
||||
bool _longActionLabel = false;
|
||||
double _sliderValue = 0.25;
|
||||
|
||||
Padding _configRow(List<Widget> children) => Padding(
|
||||
padding: const EdgeInsets.all(8.0), child: Row(children: children));
|
||||
Padding _padRow(List<Widget> children) => Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(children: children),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(padding: const EdgeInsets.only(left: 50.0), child: Column(
|
||||
children: <Widget>[
|
||||
_configRow(<Widget>[
|
||||
_padRow(<Widget>[
|
||||
Text('Snack Bar configuration',
|
||||
style: Theme.of(context).textTheme.bodyLarge),
|
||||
]),
|
||||
_configRow(
|
||||
_padRow(
|
||||
<Widget>[
|
||||
const Text('Fixed'),
|
||||
Radio<SnackBarBehavior>(
|
||||
@@ -79,7 +82,7 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
||||
),
|
||||
],
|
||||
),
|
||||
_configRow(
|
||||
_padRow(
|
||||
<Widget>[
|
||||
const Text('Include Icon '),
|
||||
Switch(
|
||||
@@ -92,7 +95,7 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
||||
),
|
||||
],
|
||||
),
|
||||
_configRow(
|
||||
_padRow(
|
||||
<Widget>[
|
||||
const Text('Include Action '),
|
||||
Switch(
|
||||
@@ -117,7 +120,7 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
||||
),
|
||||
],
|
||||
),
|
||||
_configRow(
|
||||
_padRow(
|
||||
<Widget>[
|
||||
const Text('Multi Line Text'),
|
||||
Switch(
|
||||
@@ -130,6 +133,21 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
||||
),
|
||||
],
|
||||
),
|
||||
_padRow(
|
||||
<Widget>[
|
||||
const Text('Action new-line overflow threshold'),
|
||||
Slider(
|
||||
value: _sliderValue,
|
||||
divisions: 20,
|
||||
label: _sliderValue.toStringAsFixed(2),
|
||||
onChanged: _snackBarBehavior == SnackBarBehavior.fixed ? null : (double value) {
|
||||
setState(() {
|
||||
_sliderValue = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
]
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
ElevatedButton(
|
||||
child: const Text('Show Snackbar'),
|
||||
@@ -163,6 +181,7 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
||||
behavior: _snackBarBehavior,
|
||||
action: action,
|
||||
duration: const Duration(seconds: 3),
|
||||
actionOverflowThreshold: _sliderValue,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user