Hi mate i am totally new flutter i trying increase margin from all side corsorelSliderBar which we are calling inside widget but i am unable to call padding its giving me error can any one help me how to increase margin all 4 side .
@override
Widget build(BuildContext context) {
return Obx(() => dashboardViewModel.loading.value == true
? const Center(
child: CircularProgressIndicator(
color: red,
))
: Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).primaryColor,
leading: Center(
child: SizedBox(
height: 40,
width: 40,
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Image.asset(
'assets/images/vr_logo.png',
fit: BoxFit.cover,
height: 10,
width: 10,
),
)),
),
title: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
dashboardViewModel.dashboardDetail.data?.garageName ?? "",
style: white40017,
),
Text(
dashboardViewModel.dashboardDetail.data?.garageOwnerName ??
"",
style: white50014,
)
],
),
actions: [
IconButton(
icon: const Icon(Icons.notifications_none_sharp),
onPressed: () {
context.push(const NotificationScreen());
},
),
],
),
body: SizedBox(
// color: Colors.amberAccent,
height: size(context).height,
width: size(context).width,
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
trackingTopBar(context),
Text(
"Overview",
style: black60018,
),
progressAndJob(context),
corsorelSliderBar(context),
amountBar(context),
customerStatusBar(context)
]),
),
),
));
}
CustomCard corsorelSliderBar(BuildContext context) {
return CustomCard(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
title: Text(
"",
style: yellow90024,
),
width: size(context).width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: const DecorationImage(
image: AssetImage("assets/images/background_image_1.png"))),
);
}
This is my code i am trying to increase margin from all 4 side but i am unable to please help me in this .
Thanks
2
Answers
First of all make sure you imported the material library!
This library contains Padding.
Try to add padding with a shortcut.
You have to put your cursor on the widget name and press
Alt
+Enter
(orOption
+Return
on a Mac) in Android Studio.Then you have to choose Add padding from the menu.
It should give you something like this:
you could also try:
Since in your´e example left and right are the same and top and bottom are the same, we could simplify EdgeInsets to
A very good tutorial about paddings in flutter is there.
There is a full code example about Paddings: