首页 > 解决方案 > 没有标题的颤振对话框

问题描述

我的代码

return Dialog(
  insetPadding: EdgeInsets.all(50),
  elevation: 0,
  backgroundColor: Colors.transparent,
  child: ClipRRect(
    borderRadius: BorderRadius.circular(20.0),
    child: Scaffold(
      appBar: AppBar(
        title: Text("Select a service"),
        automaticallyImplyLeading: false,
        actions: [
          IconButton(
            icon: Icon(MdiIcons.close),
            onPressed: () => Navigator.pop(context)
        )]
      ),
      body: Text("This is just a test")
      )
  ));

如何删除顶部不需要的标题区域?

带有额外标题的对话框

标签: flutter

解决方案


不要在 Dialog 中使用 Scaffod 小部件!你实际上并不需要那个。使用这样的列和行使其变得简单:

return Dialog(
  insetPadding: EdgeInsets.all(50),
  elevation: 0,
  backgroundColor: Colors.transparent,
  child: ClipRRect(
    borderRadius: BorderRadius.circular(20.0),
    child: Container(
          child: Column(childre: [
              Row(children:[Text("Select a service"), IconButton(
            icon: Icon(MdiIcons.close),
            onPressed: () => Navigator.pop(context)
        )],
      ), // use this row for top bar and your action button, and use space between and wrap this row with a container for colors and etc
          Container(child: Text("This is just a test")) // use this Container for rest
      ])  
  ));

推荐阅读