Replace Override App Bar Back Button
Complete Code For Replace Override App Bar Back Button In Flutter
main.dart
import 'package:flutter/material.dart'; void main() { runApp(MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Navigate to Next Screen', home: FirstScreen(), )); } class FirstScreen extends StatelessWidget { gotoNextActivity(BuildContext context){ Navigator.push( context, MaterialPageRoute(builder: (context) => SecondScreen()), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Color(0xFF880E4F), title: Text('Home Activity Screen'), ), body: Center( child: RaisedButton( child: Text('Navigate To Second Screen'), color: Colors.pink, textColor: Colors.white, onPressed: () { gotoNextActivity(context); }), ), ); } } class SecondScreen extends StatelessWidget { goBack(BuildContext context){ Navigator.pop(context); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Color(0xFF880E4F), automaticallyImplyLeading: true, title: Text('OverRide AppBar BACK Button'), leading: IconButton(icon:Icon(Icons.home), onPressed: () {goBack(context);}, ) ), body: Center( child: RaisedButton( onPressed: () {goBack(context);}, color: Colors.pink, textColor: Colors.white, child: Text('Go Back To Previous Screen'), ), ), ); } }