简体   繁体   中英

How can I achieve this design with flutter?

I tried using tab bar to solve it but it didn't work

You can use the ClipRRect widget:

Scaffold(
      body: Padding(
        padding: EdgeInsets.all(8.0),
        child: Row(
          children: [
            ClipRRect(
              borderRadius: BorderRadius.circular(20),
              child: Container(
                width: 100,
                color: Colors.red,
                child: Text(
                  'Healthy',
                  textAlign: TextAlign.center,
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
            SizedBox(
              width: 10,
            ),
            ClipRRect(
              borderRadius: BorderRadius.circular(20),
              child: Container(
                width: 100,
                color: Colors.red,
                child: Text(
                  'Healthy',
                  textAlign: TextAlign.center,
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
          ],
        ),
      ),
    );

Result:

在此处输入图像描述

Row(
            children: [
              //unselected Chip
              ActionChip(
                onPressed: (){

                },
                shape: StadiumBorder(side: BorderSide()),
                label: Text("History"),
                backgroundColor: Colors.white,
              ),
              //selected Chip
              ActionChip(
                onPressed: (){

                },
                label: Text("Funny Stories"),
                shape: StadiumBorder(side: BorderSide(color: Colors.orange)),
                backgroundColor: Colors.orange,
              )
            ],
          ),

output: 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM