Expand The App bar in Flutter to Allow Multi-Line Title?

前端 未结 6 952
名媛妹妹
名媛妹妹 2021-02-04 02:28

Does anyone know how I can create an app bar with a multi-line title, as per the material guidelines show here?

https://material.io/design/components/app-bars-top.html#

6条回答
  •  日久生厌
    2021-02-04 02:57

    You can use RichText:

              SliverAppBar(
            flexibleSpace: FlexibleSpaceBar(
              background: Container(
                color: Colors.indigoAccent,
              ),
              title: RichText(
                text: TextSpan(children: [
                  TextSpan(
                    text: Constants.homePageTitle,
                    style: textTheme.headline,
                  ),
                  TextSpan(text: "\n"),
                  TextSpan(
                    text: Constants.homePageSubtitle,
                    style: textTheme.subtitle,
                  )
                ]),
              ),
              titlePadding: EdgeInsets.only(left: 10, bottom: 20),
            ),
            floating: true,
            backgroundColor: Colors.greenAccent,
            expandedHeight: 150.0,
          ),
    

提交回复
热议问题