Home > front end >  Why flutter AppBar's automaticallyImplyLeading attribute has no effect?
Why flutter AppBar's automaticallyImplyLeading attribute has no effect?

Time:08-20

In main.dart file, I set appBar Theme as follows.

AppBarTheme(
  color: AppColors.colorWhite,
  elevation: 0,
  iconTheme: IconThemeData(
    color: AppColors.colorBlack
  ),
  centerTitle: false,
),

And then, the result of this appBarTheme is shown as following image. enter image description here

But, some pages show a back button and some pages do not.

Showing a back button page's code is this.

return AppBar(
  title: KoreanText(
  TextValues.myPageAppBarText,
    style: TextStyle().pageTitle,
  ),
);

And, not showing page's code is this.

return AppBar(
  title: KoreanText(
    controller.formatCurrentDate(),
    style: TextStyle().pageTitle,
  ),
  actions: [
    _buildAppBarActions(),
  ],
);

In addition, the automaticallyImplyLeading attribute in all Screen's AppBar did not work at all.

Could you tell me which part of code is wrong in mine...?


Edit 1

I am using GetX Library for state management.

And, only bottom navigation's child screen does not have a back button.

A parent page with bottom navigation bar is a main page, child one is a home page.

The main page and home page is not a relation of child routing, but the main page has a home page inside it.

In upper case, the home page's back button is not showing.

CodePudding user response:

Back button is not showing when navigating using bottom navigation bar, because it doesn't push new screens on your navigation stack contrary to when using Get.to() or Get.toNamed() or Navigator.push(). The back icon/button is only implied when there's more than one item on your navigation stack.

  • Related