Appbar Back Button Flutter

Cakra Budiman·2023년 4월 6일
1
post-thumbnail

You can add a back button to your AppBar in flutter by utilizing the AppBar widget and setting the leading property to an IconButton with a BackButton icon. This will allow you to add a back button to your AppBar. This is just one illustration

코드를 입력하세요AppBar(
  leading: IconButton(
    icon: Icon(Icons.arrow_back),
    onPressed: () {
      // Navigate back to the previous screen by popping the current route
      Navigator.of(context).pop();
    },
  ),
  title: Text('My App'),
),

In this demonstration, we've made the leading property of the AppBar more interesting by including an IconButton with an arrow back icon. The onPressed callback is invoked when the user clicks the button, which pops the currently selected route and returns the user to the screen they were on before.

This AppBar widget will need to be encased in a Scaffold widget, and the body attribute of the Scaffold widget will need to be set to the content of the screen.

0개의 댓글