This is my container. I want to move the copy button to the right. How can I do?
This is my code.
Container(
child: Row(
children: [
const SizedBox(
width: 10,
),
Flexible(
child: Text(
"",
),
),
child: IconButton(
onPressed: setClipboard,
icon: const Icon(
Icons.copy,
),
),
const SizedBox(
width: 15,
),
],
),
),
I skipped my decoration of container.
2
Answers
There are multiple ways to achieve this,
Another way by using row,
I hope this will solve your issue and you can understand overall procedure.
You just can force the text to allocate the remaining space of the row: by setting
fit: FlexFit.tight
which makes the flexible widget equal toExpanded
widgetNote:
SizedBox
s have been replaced by padding.Or, you can put a spacer between the text and the icon button:
or setting Row’s
mainAxisAlignment
tospaceBetween
.Hope it helps you.