I need to move the number to the center of the Card and put the play button at the bottom right of the Card. I hope you can help me. Thank you
@override
Widget build(BuildContext context) {
return Card(
color: const Color(0x665050f1),
child: ListTile(
title: Text(
widget.index.toString(),
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 40.0,
color: Colors.white,
fontWeight: FontWeight.w700,
),
),
trailing: IconButton(
icon: Icon(
Icons.play_arrow,
size: 50.0,
color: _playing
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.onBackground.withOpacity(.5),
),
onPressed: _playing ? null : _play,
),
),
);
}
}
CodePudding user response:
Use iconSize
instead of size
of Icon on IconButton
. I think it would be better to use Stack
in this case.
SizedBox(
height: 200,
width: 200,
child: Card(
color: const Color(0x665050f1),
child: Stack(
children: [
Align(
alignment: Alignment.center,
child: Text(
"1",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 40.0,
color: Colors.white,
fontWeight: FontWeight.w700,
),
),
),
Positioned(
right: 0, //changes to have some gap
top: 0,
child: IconButton(
alignment: Alignment.center,
iconSize: 50,
icon: Icon(Icons.play_arrow,
// size: 50.0,
color:
// _playing
// ?
Theme.of(context).colorScheme.primary
// : Theme.of(context).colorScheme.onBackground.withOpacity(.5),
),
onPressed: () {}
// _playing ? null : _play,
),
),
],
),
),
),
More about Stack