I am very new to Flutter development. I am trying to make a button that would be on the bottom right of the page, but it is not working.
import 'package:flutter/material.dart';
class GoBack extends StatelessWidget {
const GoBack({required this.onGoBack, super.key});
final void Function() onGoBack;
@override
Widget build(context) {
return OutlinedButton(
onPressed: onGoBack,
style: OutlinedButton.styleFrom(
backgroundColor: const Color.fromARGB(208, 93, 0, 255),
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
minimumSize: const Size(60, 60),
),
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.arrow_circle_left_rounded),
]),
);
}
}
I tried adding:
alignment: Alignment.bottomRight,
I am probably using this wrong tho.
2
Answers
I think it is better for you to use
floatingActionButtonLocation
property ofScaffold
widget. You can customize the button style with theFloatingActionButton
widget.);
You can visit https://blog.logrocket.com/flutter-floatingactionbutton-a-complete-tutorial-with-examples/ or https://api.flutter.dev/flutter/material/FloatingActionButton-class.html to see more details.
you might use FloatingActionButton within Scaffold.
It is located at right bottom by default.
Check documentation here :
https://api.flutter.dev/flutter/material/FloatingActionButton-class.html
You can also use
Therefore you can play with button location.