Reputation: 2449
I have a Check box
as the below code:
DelayedAnimation(
child: CheckboxListTile(
title: const Text('Check privacy & policy'),
value: timeDilation != 1.0,
onChanged: (bool value) {
setState(() {
timeDilation = value ? 5.0 : 1.0;
});
},
secondary: Image.asset(
'assets/images/policy_ic.png',
height: 30,
),
),
delay: delayedAmount + 4500,
),
and it's look like the below image:
Now I need to set padding or margin right for the text
and image to be like the below image:
I hope some one could help me to solve this problem.
Upvotes: 0
Views: 99
Reputation: 744
What you can do is simply wrap the CheckboxListTile in a Padding widget and only set the horizontal property.
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40.0), // Set it to your liking
child: CheckboxListTile(
title: const Text('Check privacy & policy'),
value: timeDilation != 1.0,
onChanged: (bool value) {
setState(() {
timeDilation = value ? 5.0 : 1.0;
});
},
secondary: Image.asset(
'assets/images/policy_ic.png',
height: 30,
),
),
),
Upvotes: 1
Reputation: 541
I would use a row instead of the CheckboxListTile:
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Image.asset(
'assets/images/policy_ic.png',
height: 30,
),
Container(
margin: EdgeInsets.all(10),
child: Text(
'Check privacy & policy',
style: Theme.of(context).textTheme.headline5,
),
),
Checkbox(
value: timeDilation != 1.0,
onChanged: (bool value) {
setState(() {
timeDilation = value ? 5.0 : 1.0;
});
}),
],
)
Edit: Create a custom widget like this:
class CustomTile extends StatefulWidget {
@override
_CustomTileState createState() => _CustomTileState();
}
class _CustomTileState extends State<CustomTile> {
bool value = false;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
setState(() {
value = !value;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Icon(Icons.extension),
Container(
margin: EdgeInsets.all(10),
child: Text(
'Check privacy & policy',
style: Theme.of(context).textTheme.headline5,
),
),
Checkbox(
value: value,
onChanged: (bool value) {},
)
],
),
);
}
}
Upvotes: 1