Home > Software design >  Flutter Center Title Not True Pt. 2
Flutter Center Title Not True Pt. 2

Time:10-04

I used centerTitle successfully in the past, but it is not working this time. I get Unexpected token ';' error at bottom of page. Appreciate any suggestions.

return Scaffold(
        key: scaffoldKey,
        backgroundColor: bgcolor,
        appBar: AppBar(
          automaticallyImplyLeading: false,
          backgroundColor: hdrcolor,
          centerTitle: true,
          title: Text(
              'My App Name',
              style: TextStyle(
                  fontFamily: 'Noto Sans', color: hdrtxtcolor, fontSize: 28),
            ),
          ),
          actions: [
            InkWell(
              onTap: () async {
                await Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => ProfilePageWidget(),
                  ),
                );
              },
              child: Padding(
                padding: const EdgeInsets.fromLTRB(0, 0, 8, 0),
                child: Icon(
                  Icons.settings,
                  color: txtcolor,
                  size: 24,
                ),
              ),
            ),
          ],
        ),

CodePudding user response:

Replace the last , with ; like that

return Scaffold(
        key: scaffoldKey,
        backgroundColor: bgcolor,
        appBar: AppBar(
          automaticallyImplyLeading: false,
          backgroundColor: hdrcolor,
          centerTitle: true,
          title: Text(
              'My App Name',
              style: TextStyle(
                  fontFamily: 'Noto Sans', color: hdrtxtcolor, fontSize: 28),
            ),
          ),
          actions: [
            InkWell(
              onTap: () async {
                await Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => ProfilePageWidget(),
                  ),
                );
              },
              child: Padding(
                padding: const EdgeInsets.fromLTRB(0, 0, 8, 0),
                child: Icon(
                  Icons.settings,
                  color: txtcolor,
                  size: 24,
                ),
              ),
            ),
          ],
        ); // <--------

You are returning a Scaffold and the return statement needs to end in a ;

CodePudding user response:

Try below code hope its helpful to you. refer AppBar Image

  • Related