Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Scaffold Appbar not showing the back button

Tags:

flutter

dart

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);
  }
}
like image 810
Vinicius Budel Avatar asked Feb 06 '20 14:02

Vinicius Budel


2 Answers

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,
          ),
        ),
      )
like image 151
Ayoub Boumzebra Avatar answered Oct 07 '22 02:10

Ayoub Boumzebra


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,
), 
like image 7
thanhbinh84 Avatar answered Oct 07 '22 01:10

thanhbinh84