1

我留下了整个代码片段,主要想法是有一个文本字段,通过使用键盘向我显示一系列元素,在描述变量中,我有那个元素要选择,这很好用,唯一的问题是,如何让我的警报对话框包含所有正确的注释。

 return await Get.generalDialog(
    barrierLabel: "Barrier",
    barrierDismissible: false,
    transitionBuilder: (context, a1, a2, widget) {
      return StatefulBuilder(builder: (context, setState) {
        return Transform.scale(
            scale: a1.value,
            child: Opacity(
              opacity: a1.value,
              child: Dialog(
                insetAnimationCurve: Curves.bounceOut,
                insetPadding: EdgeInsets.only(right: 20, left: 20),
                //backgroundColor: colorFour(),
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(12.0),
                ),
                child: SingleChildScrollView(
                  child: Container(
                    height: 340,
                    child: Column(
                      children: <Widget>[
                        Container(
                          alignment: Alignment.topCenter,
                          height: 50,
                          decoration: BoxDecoration(
                            color: Colors.red,
                            borderRadius: BorderRadius.only(
                              topLeft: Radius.circular(12),
                              topRight: Radius.circular(12),
                            ),
                          ),
                          padding: EdgeInsets.all(5),
                          child: Center(
                            child: Text(
                              title,
                              style: TextStyle(
                                  color: Colors.white,
                                  fontSize: 18,
                                  fontWeight: FontWeight.w600),
                              maxLines: 2,
                              textAlign: TextAlign.center,
                            ),
                          ),
                        ),
                        SingleChildScrollView(
                            padding: EdgeInsets.only(left: 10, right: 10),
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.start,
                              crossAxisAlignment:
                                  CrossAxisAlignment.stretch,
                              children: [
                                Container(
                                  margin: EdgeInsets.only(top: 10),
                                  child: TextFormField(
                                    controller: controller,
                                    decoration: InputDecoration(
                                        border: OutlineInputBorder(
                                            gapPadding: 5.0)),
                                    keyboardType: TextInputType.text,
                                    maxLines: 1,
                                    onChanged: (String cadena) async {
                                      listado = pivote
                                          .where((x) => x.descripcion
                                              .split("/")[value]
                                              .toLowerCase()
                                              .contains(
                                                  cadena.toLowerCase()))
                                          .toList();
                                      setState(() {});
                                    },
                                  ),
                                ),
                                Container(
                                  height: 200,
                                  margin: EdgeInsets.only(
                                      top: 10, bottom: 10.0),
                                  decoration: BoxDecoration(
                                      borderRadius: BorderRadius.all(
                                          Radius.circular(5)),
                                      border: Border.all(
                                          color: Colors.grey, width: 1)),
                                  child: ListView.builder(
                                      padding: const EdgeInsets.all(0.0),
                                      physics: BouncingScrollPhysics(),
                                      itemCount: listado.length,
                                      shrinkWrap: true,
                                      scrollDirection: Axis.vertical,
                                      itemBuilder: (context, index) {
                                        return Container(
                                          height: 34,
                                          child: InkWell(
                                              child: SizedBox.expand(
                                                child: Align(
                                                  alignment:
                                                      Alignment.centerLeft,
                                                  child: Padding(
                                                    padding:
                                                        EdgeInsets.only(
                                                            right: 5,
                                                            left: 5),
                                                    child: Text(
                                                        listado[index]
                                                            .descripcion
                                                            .split(
                                                                "/")[value],
                                                        textAlign:
                                                            TextAlign.left),
                                                  ),
                                                ),
                                              ),
                                              onTap: () {
                                                Get.back(result: {
                                                  "item": listado[index],
                                                });
                                              }),
                                        );
                                      }),
                                ),
                              ],
                            )),
                      ],
                    ),
                  ),
                ),
              ),
            ));
      });
    },
    pageBuilder: (context, animation1, animation2) {
      return Container();
    });

在此处输入图像描述 我需要覆盖我的警报对话框,也就是说尺寸不会破坏我的设计,这发生在关注文本字段之后

4

1 回答 1

0

向我们展示一些代码来帮助您。SingleChildScrollView. 在任何情况下,将布局包装在一个Here is a very good explanation中可能是有意义的。

https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html

yourAlertDialog(
  context: context,
  builder: (BuildContext context) {
    return SingleChildScrollView(child: yourchild);
  },
);

您的布局应该包含在 Scrollview 中,我没有复制或运行此代码,但它应该是这样的:

AlertDialog(
      title: Text("title", style: TextStyle(color: ThemeColors.colorPrimary),),
      content: Container(
        width: double.maxFinite,
        child: SingleChildScrollView(
          scrollDirection: Axis.vertical,
          child: StatefulBuilder(builder: (BuildContext context1, StateSetter setState) {
            this.setState = setState;
            return Container(
                    height: 340,
                    child: Column(
                      children: <Widget>[
                        //your container
                      ],
                    ),
                  ),

     
            
          }),
        
      )),
     
    );
于 2022-02-11T06:59:27.667 回答