flutter corner radius with transparent background

后端 未结 11 1021
鱼传尺愫
鱼传尺愫 2021-01-30 15:28

Below is my code which I expect to render a round-corner container with a transparent background.

return new Container(
                //padding: const EdgeIn         


        
11条回答
  •  无人及你
    2021-01-30 16:10

    As of May 1st 2019, use BottomSheetTheme.

    MaterialApp(
        theme: ThemeData(
          // Draw all modals with a white background and top rounded corners
          bottomSheetTheme: BottomSheetThemeData(
            backgroundColor: Colors.white,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.vertical(top: Radius.circular(10))
            )
          )
        ),
    

    Introduced recently, using a theme to control the sheets style should be the most best to this problem.

    If you want to theme different bottom sheets differently, include a new Theme object in the appropriate subtree to override the bottom sheet theme just for that area.

    If for some reason you'd still like to override the theme manually when launching a bottom sheet, showBottomSheet and showModalBottomSheet now have a backgroundColor parameter. Use it like this:

     showModalBottomSheet(
        backgroundColor: Colors.transparent,
        context: context,
        builder: (c) {return NavSheet();},
      );
    

    Using the theme allows bottom sheets to be re-used regardless of the app / app's current theme, and has none of the negative side effects of setting canvas color as mentioned.

提交回复
热议问题