How do you adjust the height and borderRadius of a BottomSheet in Flutter?

后端 未结 9 1247
野性不改
野性不改 2021-02-05 03:47

I\'m probably missing something obvious here, but my BottomSheet only takes up the bottom half the screen, even though the widgets in it take up more space. So now there is scro

9条回答
  •  无人及你
    2021-02-05 04:04

    Default height for bottomSheet is half the screenSize

    If you want your bottomSheet to EXPAND according to your content DYNAMICALLY

    use below code

    showModalBottomSheet(
    isScrollControlled: true,
    context: context,
    builder: (BuildContext bc) {
      return Wrap(
          children: [...]
      )
     }
    )
    

    This will automatically expand the bottomSheet according to content inside.

    For adding a radius on top of bottomSheet return below code to `bottomSheet'

    Container(
      child: Container(
        decoration: new BoxDecoration(
          color: forDialog ? Color(0xFF737373) : Colors.white,
          borderRadius: new BorderRadius.only(
                topLeft: const Radius.circular(25.0),
                topRight: const Radius.circular(25.0))),
          child: yourWidget(),
       ),
    )
    

    Complete code meeting both requirements

    showModalBottomSheet(
    isScrollControlled: true,
    context: context,
    builder: (BuildContext bc) {
      return Wrap(
          children: [
              Container(
                     child: Container(
                      decoration: new BoxDecoration(
                        color: forDialog ? Color(0xFF737373) : Colors.white,
                        borderRadius: new BorderRadius.only(
                              topLeft: const Radius.circular(25.0),
                              topRight: const Radius.circular(25.0))),
                        child: yourWidget(),
                     ),
                  )
          ]
       )
     }
    )
    

提交回复
热议问题