android-studio - flutter 应用栏中不需要的操作按钮

标签 android-studio dart flutter

我正在构建一个屏幕,它有一个底部导航栏,我在其中放置了一个汉堡操作按钮和一个 float 按钮,还有一个应用栏,我想在其中放置我的应用程序 Logo 。

即使我没有对应用栏进行任何操作,汉堡图标仍然出现在标题的左侧。

我只想在应用栏中显示标题。

这是我的代码:

   appBar: new AppBar(
    title: new Image.asset('assets/logo/logo-home.png', fit: BoxFit.fitHeight),
    actions: null,
    backgroundColor: Colors.black,
    elevation: 0.0,
  ),


  key: _scaffoldKey,
  floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  floatingActionButton: FloatingActionButton(
    child: ImageIcon(new AssetImage("assets/icons/star.png"), color: Colors.black),
    backgroundColor: Colors.white,
    onPressed: scan,
  ),
bottomNavigationBar: BottomAppBar(
    color: Color.black,
    child: new Row(
      mainAxisSize: MainAxisSize.max,
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        IconButton(icon: Icon(Icons.menu), color: Colors.white, onPressed: ()=> _scaffoldKey.currentState.openDrawer(),),
      ],
    ),
  ),

最佳答案

如果脚手架有一个抽屉并且应用栏不包含“leading”属性(或具有空值),应用栏将在其操作中附加一个菜单图标。

它在 documents 中提到:

If the leading widget is omitted, but the AppBar is in a Scaffold with a Drawer, then a button will be inserted to open the drawer. Otherwise, if the nearest Navigator has any previous routes, a BackButton is inserted instead. This behavior can be turned off by setting the automaticallyImplyLeading to false. In that case a null leading widget will result in the middle/title widget stretching to start.

解决方案很简单,只需将应用栏中的 title 属性替换为 leading

  appBar: new AppBar(
        leading: new Image.asset('assets/logo/logo-home.png', fit: BoxFit.fitHeight),
        actions: null,
        backgroundColor: Colors.black,
        elevation: 0.0,
  ),

关于android-studio - flutter 应用栏中不需要的操作按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51579236/

相关文章:

Flutter 蓝牙打印到 Zebra

svn - 安卓工作室 : Subversion files are marked as unversioned

android - Android Studio 出现奇怪的语言问题,如何更改默认语言环境?

data-binding - 如果多行属性绑定(bind)到聚合物表达式,则聚合物 Dart 核心输入验证不起作用

dart - 如何部署Angular-Dart Web应用程序

variables - 如何在Dart/Flutter上覆盖变量

ios - 如何在没有付费开发者帐户的情况下在 ios 设备上运行用于开发的 flutter 应用程序?

android - gradle > Task :app:externalNativeBuildDebug FAILED android_gradle_build. json(没有这样的文件或目录)

android - 如何为所有新项目配置项目级别build.gradle?

dart - flutter/dart 中的 widget.something 到底调用了什么?