The PersistedFooterButtons shares backgroundColor with Scaffold. So if you change backgroundColor of Scaffold it will pick it up. And if you want your body to have different background color you can wrap it with Container or ColoredBox and give it some different color (like I did in the example below).
class Sample extends StatelessWidget {
const Sample({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: const ColoredBox(
// if you want your body to have different background color
color: Colors.grey,
child: Center(
child: Text('test'),
),
),
// this changes persistentFooterButtons background color
backgroundColor: Colors.white,
persistentFooterButtons: [
ElevatedButton(
onPressed: () {},
child: const Icon(Icons.arrow_back_ios_new),
),
ElevatedButton(
onPressed: () {},
child: const Icon(Icons.arrow_forward_ios_rounded),
),
ElevatedButton(
onPressed: () {},
child: const Text('Termina'),
)
],
);
}
}
One alternative way to tackle this situation could be to create a new Scaffold widget in a separate file and copy the source code from Flutter’s original Scaffold to your new class but with your desired modifications (meaning, change the padding to padding: EdgeInsets.all(0)).
2
Answers
The
PersistedFooterButtons
sharesbackgroundColor
withScaffold
. So if you changebackgroundColor
ofScaffold
it will pick it up. And if you want yourbody
to have different background color you can wrap it withContainer
orColoredBox
and give it some different color (like I did in the example below).Result:
This is a default hard-coded padding.
If you using the Flutter Inspector, you will see this:
If you go into the SDKs
Scaffold.dart
(Ctrl+ click on theScaffold
widget), you will see the value is hard coded:One alternative way to tackle this situation could be to create a new Scaffold widget in a separate file and copy the source code from Flutter’s original Scaffold to your new class but with your desired modifications (meaning, change the padding to
padding: EdgeInsets.all(0)
).