屏幕上显示了一个灰色的框.它未处于调试模式. 只有当我切换到释放模式时,才会出现一个灰色的框.

是什么导致了这个问题?我要怎么改变呢?

itemInfoWidget() {
  return  Container(
    height: MediaQuery.of(Get.context!).size.height * 0.55,
    width: MediaQuery.of(Get.context!).size.width,
    decoration: const BoxDecoration(
        color: Colors.black38,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(30),
          topRight: Radius.circular(30),
        ),
        boxShadow: [
          BoxShadow(offset: Offset(0, 0), blurRadius: 0, color: Colors.green),
        ]),
    padding: const EdgeInsets.symmetric(horizontal: 16),
    child: SingleChildScrollView(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          const SizedBox(
            height: 18,
          ),
          Center(
            child: Container(
              height: 8,
              width: 130,
              decoration: BoxDecoration(
                  color: Colors.black38,
                  borderRadius: BorderRadius.circular(
                    (30),
                  )),
            ),
          ),
          const SizedBox(
            height: 18,
          ),
          //name
          Row(
            children: [
              Text(
                widget.itemInfo!.name!,
                maxLines: 2,
                overflow: TextOverflow.ellipsis,
                style: const TextStyle(
                  fontWeight: FontWeight.bold,
                  color: Colors.white,
                  fontSize: 25
                ),
              ),
              const Spacer(),
              Obx(() => IconButton(
                onPressed: () {
                  if (itemDetailsController.isFavorite == true) {
                    //delete item from favorites
                    deleteItemFromFavoriteList();
                  } else {
                    //save item to user favorites
                    addItemToFavoriteList();
                  }
                },
                icon: Icon(
                  itemDetailsController.isFavorite
                      ? CupertinoIcons.bookmark_fill
                      : CupertinoIcons.bookmark,
                  color :  const Color(0xffffd400),
                  size: 25,
                ),
              )),
            ],
          ),
          SizedBox(
            height: MediaQuery.of(context).size.height * 0.01,
          ),
          //rating + rating num, tags, price
          Row(
            children: [
              const SizedBox(height: 30),
              //rating
              RatingBar.builder(
                initialRating: widget.itemInfo!.rating!,
                minRating: 1,
                direction: Axis.horizontal,
                allowHalfRating: true,
                itemCount: 5,
                itemBuilder: (context, c) => const Icon(
                  Icons.star,
                  color: Colors.amber,
                ),
                onRatingUpdate: (updateRating) {},
                ignoreGestures: true,
                unratedColor: Colors.black87,
                itemSize: 20,
              ),
              const SizedBox(
                width: 8,
              ),

              // rating num
              Text(
                "(${widget.itemInfo!.rating})",
                style: const TextStyle(
                  color: Colors.black87,
                  fontSize: 18,
                ),
              ),
            ],
          ),
          const SizedBox(height: 10),
          //tags
          Text(
            "카테고리: ${widget.itemInfo!.tags!.toString().replaceAll("[", "").replaceAll("]", "")}",
            maxLines: 2,
            overflow: TextOverflow.ellipsis,
            style: const TextStyle(
              fontSize: 18,
              color: Colors.white,
            ),
          ),
          const SizedBox(height: 10),
          //price
          Text(
            "포인트: ${widget.itemInfo!.price!}",
            style: const TextStyle(
              fontSize: 18,
              color: Colors.white,
            ),
          ),
          SizedBox(
            height: MediaQuery.of(context).size.height * 0.03,
          ),
          //모양, 색깔, 재질 박스
          // 1줄 넘어가면 재질 박스가 밑으로 이동하도록지(2 rows)
          // 1줄 안에 다 들어가면 1 row 유지하는 방법..?
          Center(
            child: Wrap(
              // 20221229
              alignment: WrapAlignment.center,
              spacing: 7,
              runSpacing: 8,
              children: [
                //색깔 박스
                Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    const Text(
                      "색깔",
                      style: TextStyle(
                        fontSize:
                        16,
                        color: Colors.white,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    const SizedBox(width: 2),
                    ...List.generate(widget.itemInfo!.colors!.length,
                            (index) {
                          return Container(
                            // height: 35,
                            padding: const EdgeInsets.symmetric(
                                vertical: 4, horizontal: 8),
                            margin: const EdgeInsets.symmetric(horizontal: 2),
                            // width: widget.itemInfo!.colors![index]
                            //             .replaceAll("[", "")
                            //             .replaceAll("]", "") ==
                            //         '얼룩덜룩한'
                            //     ? MediaQuery.of(context).size.width * 0.26
                            //     : MediaQuery.of(context).size.width * 0.15,
                            decoration: const BoxDecoration(boxShadow: [
                              BoxShadow(
                                  offset: Offset(1, 1),
                                  blurRadius: 2,
                                  color: Colors.black38),
                            ], color: Color(0xff073215)),
                            alignment: Alignment.center,
                            child: Text(
                              widget.itemInfo!.colors![index]
                                  .replaceAll("[", "")
                                  .replaceAll("]", ""),
                              maxLines: 2,
                              overflow: TextOverflow.ellipsis,
                              style: const TextStyle(
                                fontSize: 16,
                                color: Colors.white,
                              ),
                            ),
                          );
                        }),
                    const SizedBox(width: 3),
                  ],
                ),
                const Spacer(),
                Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    const Text(
                      "모양",
                      style: TextStyle(
                        fontSize: 16,
                        color: Colors.white,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    const SizedBox(width: 2),
                    ...List.generate(widget.itemInfo!.shapes!.length,
                            (index) {
                          return Container(
                            // height: 35,
                            padding: const EdgeInsets.symmetric(
                                vertical: 4, horizontal: 8),
                            margin: const EdgeInsets.symmetric(horizontal: 2),
                            // width: MediaQuery.of(context).size.width * 0.15,
                            decoration: const BoxDecoration(boxShadow: [
                              BoxShadow(
                                  offset: Offset(1, 1),
                                  blurRadius: 2,
                                  color: Colors.black38),
                            ], color: Color(0xff073215)),
                            alignment: Alignment.center,
                            child: Text(
                              widget.itemInfo!.shapes![index]
                                  .replaceAll("[", "")
                                  .replaceAll("]", ""),
                              maxLines: 1,
                              overflow: TextOverflow.ellipsis,
                              style: const TextStyle(
                                fontSize: 16,
                                color: Colors.white,
                              ),
                            ),
                          );
                        }),
                    const SizedBox(width: 2),
                  ],
                ),
                const Spacer(),
                Wrap(children: [
                  Row(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      const Text(
                        "재질",
                        style: TextStyle(
                          fontSize: 16,
                          color: Colors.white,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      const SizedBox(width: 2),
                      ...List.generate(widget.itemInfo!.materials!.length,
                              (index) {
                            return Container(
                              // height: 35,
                              padding: const EdgeInsets.symmetric(
                                  vertical: 4, horizontal: 8),
                              margin: const EdgeInsets.symmetric(horizontal: 2),
                              // width:  widget.itemInfo!.materials![index]
                              //                 .replaceAll("[", "")
                              //                 .replaceAll("]", "") ==
                              //             '깍지벌레' ||
                              //         widget.itemInfo!.materials![index]
                              //                 .replaceAll("[", "")
                              //                 .replaceAll("]", "") ==
                              //             '거미줄'
                              //     ? MediaQuery.of(context).size.width * 0.23
                              //     : MediaQuery.of(context).size.width * 0.15,
                              decoration: const BoxDecoration(boxShadow: [
                                BoxShadow(
                                    offset: Offset(1, 1),
                                    blurRadius: 2,
                                    color: Colors.black38),
                              ], color: Color(0xff073215)),
                              alignment: Alignment.center,
                              child: Text(
                                widget.itemInfo!.materials![index]
                                    .replaceAll("[", "")
                                    .replaceAll("]", ""),
                                maxLines: 1,
                                overflow: TextOverflow.ellipsis,
                                style: const TextStyle(
                                  fontSize: 16,
                                  color: Colors.white,
                                ),
                              ),
                            );
                          }),

                    ],
                  ),
                ]),
              ],
            ),
          ),
          SizedBox(
            height: MediaQuery.of(context).size.height * 0.025,
          ),
          //description
          const Text(
            "특징: ",
            style: TextStyle(
              fontSize: 18,
              color: Colors.white,
              fontWeight: FontWeight.bold,
            ),
          ),
          SizedBox(
            height: MediaQuery.of(context).size.height * 0.005,
          ),
          Text(
            widget.itemInfo!.description!,
            textAlign: TextAlign.justify,
            style: const TextStyle(
              fontSize: 18,
              color: Colors.white70,
            ),
          ),
          SizedBox(
            height: MediaQuery.of(context).size.height * 0.035,
          ),
          //관찰 올리기 - 버튼
          Material(
            elevation: 4,
            color: const Color(0xffBF5F27),
            borderRadius: BorderRadius.circular(10),
            child: InkWell(
              onTap: () {
                Get.to(() => UserUploadReviewsScreen(
                  itemInfo: widget.itemInfo,
                ));
              },
              borderRadius: BorderRadius.circular(20),
              child: Container(
                alignment: Alignment.center,
                height: 50,

                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: const [
                    Icon(
                      CupertinoIcons.camera_fill,
                      color: Colors.white,
                    ),
                    SizedBox(
                      width: 15,
                    ),
                    Text("관찰 올리기",
                        style: TextStyle(
                          fontSize: 18,
                          color: Colors.white,
                        )),
                  ],
                ),
              ),
            ),
          ),
          SizedBox(
            height: MediaQuery.of(context).size.height * 0.035,
          ),
        ],
      ),
    ),
  );
}

我想展示里面的东西,而不是一个灰色的盒子.

推荐答案

正如我所 comments 的,如果你在释放模式下看到一个灰色的方框,这意味着你有某种类型的error.

debug模式下运行时,您应该能够查看错误,并在控制台中查看错误以正确调试它.错误将显示为红色.

这可能是任何类型的错误,但对我来说,当我在错误的位置使用Expanded小工具时,我以为我可以忽略它,但在发布模式下,我有一个白色屏幕.

See also

Explain that a grey screen on release is indicative of an error (and how to find the error).

Flutter相关问答推荐

获取屏幕大小的滚动视图与动态大小?

使用Flutter 提供程序包加载状态应用程序时,在自定义按钮中显示CircularProgressIndicator

在Flutter 中创建自定义Snackbar类

Flutter creating Constant.dart InputDecoration section put pass in hintText

blocTest错误:没有从`when()`中调用方法存根

Flutter 蜂巢不能正常工作,我正在使用蜂巢在设备上存储数据,但当我关闭并重新启动应用程序时,我失go 了一切

Wired Firebase错误-[CLOUD_FIRESTORE/UNAvailable]该服务当前不可用

如何使Flutter 边框宽度在外面而不是在里面?

在允许屏幕 Select 和点击的同时保持通用对话框显示

在 Flutter 中,SpinEdit 叫什么?

如何在 Flutter (iOS) 中解决这个问题

Agora VideoCall 不显示远程视频网格

在不丢失游戏状态的情况下从 Flame 游戏导航到 Flutter 小部件

type '({bool growable}) => List' 不是类型转换中类型 'List' 的子类型

Firestore:缓存和读取数据

在 Flutter 中,您什么时候应该更喜欢Widget继承而不是组合?

TextSpan 避免符号字符串组上的换行符

使用 Firebase/Flutter 进行应用判断 - 100% 无效请求

在自动完成中 Select 值后保持键盘焦点

Flutter Firebase 可以在真实设备上运行,而不是在 Android 模拟器上运行