I have a problem. I have an app with page navigations, and when I navigate to another page, a back arrow appears in the AppBar, which moves the text to the side. And I need it to be constantly in the center
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(icon: Icon(Icons.account_circle_rounded), onPressed: () { },),
title: Align(
alignment: Alignment.center,
child: Text('Some text'),
),
),
body: Container(...)
This is the AppBar Code
Navigator.push(context, MaterialPageRoute(
builder: (context) => OrderWidget())
);
In this way I go to a new page
CodePudding user response:
Instead of Align
your title, set centerTitle
true in your AppBar
for center title, like this:
appBar: AppBar(
centerTitle: true,
leading: IconButton(
icon: Icon(Icons.account_circle_rounded),
onPressed: () {},
),
title: Text('Some text'),
),