Search code examples
flutterdartwidgetcross-platformappbar

Can I remove space between leading and actions?


I tried to remove space between leading and actions icon button but I can't, I tried to put all in row but it doesn't work!

 appBar: AppBar(
        centerTitle: true,
        title: Text(
          'data',
          textAlign: TextAlign.center,
        ),
        actions: [
          IconButton(icon: Icon(Icons.filter_sharp), onPressed: () {}),
          Directionality(
              textDirection: TextDirection.rtl,
              child: IconButton(
                  icon: Icon(Icons.arrow_back_ios), onPressed: () {})),
        ],
                leading: IconButton(icon: Icon(Icons.search), onPressed: () {}),

        backgroundColor: Theme.of(context).primaryColor,
      ),

Solution

  • I fixed it by adding alignment to the iconbutton like this:

    appBar: AppBar(
            centerTitle: true,
            title: Text(
              'data',
              textAlign: TextAlign.center,
            ),
            actions: [
              IconButton(
                  icon: Icon(Icons.filter_sharp),
                  onPressed: () {},
                  alignment: Alignment(5, 0.0)),
              Directionality(
                  textDirection: TextDirection.rtl,
                  child: IconButton(
                      icon: Icon(Icons.arrow_back_ios), onPressed: () {})),
            ],
            leading: IconButton(icon: Icon(Icons.search), onPressed: () {}),
            backgroundColor: Theme.of(context).primaryColor,
          ),