Search code examples
flutterflutter-layout

Flutter: CupertinoNavigationBar with leading icon and title


how can I create in Flutter a leading item of Navigation bar with back icon and title of the previous scaffold. Have a look in a picture:

enter image description here

I've tried to put a Text widget inside a Row but got an overflow.

CupertinoNavigationBar(
    middle: Text('New report'),
    leading: Align(
      alignment: Alignment(-1.5, -1),
      child: IconButton(
        onPressed: () {
          Navigator.pop(context);
        },
        icon: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Icon(
              CupertinoIcons.left_chevron,
              color: CupertinoColors.destructiveRed,
            ),
          ],
        ),
      ),
    ),
  ),

Thanks in advance!


Solution

  • Your leading could be a Row containing the Icon and the text: Something like that:

    CupertinoNavigationBar(
        middle: Text('New report'),
        leading: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                Icon(
                  CupertinoIcons.left_chevron,
                  color: CupertinoColors.destructiveRed,
                ),
                 Text('Reports')
                 ],
            ),
        ),
      ),