'Flutter Scaffold Appbar not showing the back button
My class is not showing the back button in the AppBar,
Already try put this.automaticallyImplyLeading = true,
import 'package:carros/pages/carro/carro.dart';
import 'package:flutter/material.dart';
class CarroPage extends StatelessWidget {
Carro carro;
CarroPage(this.carro);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(carro.nome),
),
body: _body(),
);
}
_body() {
return Image.network(carro.urlFoto);
}
}
Solution 1:[1]
Try to make your own back button :
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
iconSize: 20.0,
onPressed: () {
_goBack(context);
},
),
centerTitle: true,
title: Text('back')),
And the _goBack method :
_goBack(BuildContext context) {
Navigator.pop(context);
}
Solution 2:[2]
I used this solution, it works for me, add leading inside AppBar:
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0.0,
titleSpacing: 10.0,
centerTitle: true,
leading: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Icon(
Icons.arrow_back_ios,
color: Colors.black54,
),
),
)
Solution 3:[3]
According to the document, if you use Material design and push a screen, the back button should be there.
https://api.flutter.dev/flutter/material/AppBar-class.html
But sometimes the back button and app bar background color are the same, so it is invisible. Let try to click on the leading button zone or set to a contrary color
appBar: AppBar(
iconTheme: IconThemeData(
color: Colors.black, //change your color here
),
title: Text("Sample"),
centerTitle: true,
),
Solution 4:[4]
In order for the back key to come, the part that goes to that page is "Navigator.pushNamed (context, '/ brand new');" For example, it should be in the form of.
Solution 5:[5]
- you should to be sure a create appbar : AppBar()
- and should to set a color in the theme until maybe icon is white
Solution 6:[6]
The back buttons were all there by default. I built and deployed, the back buttons are there for some users, not for others. My goodness, this platform is getting buggier and buggier by the day. I shouldn't have to explicitly create a back button and wire in a manual pop function when the documentation clearly states it's part of the gig, and it works on some devices under some circumstances, with absolutely no consistency. (sigh)
Solution 7:[7]
To show back button only with custom color , and appbar background white or any color
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white,
leading: IconButton(
color: Colors.black,
icon: Icon(Icons.arrow_back_ios),
iconSize: 20.0,
onPressed: () {
Navigator.pop(context);
},
),
centerTitle: true,
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Ayoub Boumzebra |
Solution 3 | thanhbinh84 |
Solution 4 | Hasan CAN |
Solution 5 | Osama M.Hasanain |
Solution 6 | ChrisH |
Solution 7 | Quick learner |