ParentDataWidget 的错误使用。内颤抽屉

时间:2020-12-23 11:33:14

标签: android ios flutter dart navigation-drawer

我尝试使用包含 Drawer 和其他 drwaerheader 小部件的列表视图向我的应用程序添加颤振 ListTile,这是我的代码:

  Widget build(BuildContext context) {
    return Drawer(
      child: ListView(
        children: [
          drawer_header(),
          menu_shape(context, "الرئيسية", Icons.home, NewOrdersList()),
          menu_shape(context,"الاوردرات السابقة", Icons.bookmark_border,PreviousOrder()),
          menu_shape(context,"المحفظة", Icons.bookmark_border, WalletScreen()),
          menu_shape(context,"محفظة 15 يوم", Icons.bookmark_border, WalletOne(false)),
          menu_shape(context,"اتصل بنا", Icons.contact_phone, Chat()),
          menu_shape(context,"الملف الشخصى", Icons.person_pin, Profile()),
          Spacer(),
          Container(
            width: SizeConfig.screenWidth / 1.5,
            height: SizeConfig.screenHeight / 15,
            child: Card(
              color: dark_red,
              child: Center(
                  child: Text(
                "بريك ساعة",
                style: TX_STYLE_white_14point5,
              )),
            ),
          ),
          Container(
            width: SizeConfig.screenWidth / 1.5,
            child: Card(
              color: dark_yellow,
              child: Center(child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Text("ساعات اضافية", style: TX_STYLE_black_14,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      counter_shape("1"),
                      counter_shape("2"),
                      counter_shape("4"),


                    ],
                  ),
                  SizedBox(height: SizeConfig.blockSizeVertical,)
                ],

              )),
            ),
          ),
          Padding(
            padding: PADDING_symmetric(horizontalFactor: 2),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  width: SizeConfig.screenWidth / 5,

                  decoration: BoxDecoration(
                      color: dark_yellow,
                      borderRadius: BorderRadius.circular(12)
                  ),
                  child: Center(child: Text("English")),
                ),
                GestureDetector(
                  onTap: () async {
                    ApiServices().doManualLogOut(context);
                  },
                  child: Container(
                    width: SizeConfig.screenWidth / 4,

                    decoration: BoxDecoration(
                        color: Colors.grey,
                        borderRadius: BorderRadius.circular(12)
                    ),
                    child: Center(child: Text(
                      "تسجيل الخروج", style: TextStyle(fontSize: 12),)),
                  ),
                ),
              ],
            ),
          ),
          SizedBox(height: SizeConfig.blockSizeVertical,)
        ],
      ),


    );
  }

这是我用过的 menu_shapedrawer_header

  Widget menu_shape(BuildContext context, String title,icon, Widget targetWidget){
    return GestureDetector(
      onTap: () {
        NavigationServices().goToPush(context, targetWidget);
      },
      child: ListTile(leading: Icon(icon,),title: Text(
        title,
        style: TextStyle(color: Colors.black,fontSize: 12),
      ),),
    );
  }

  Widget drawer_header(){
    return Container(
        color: dark_red,
        height: SizeConfig.screenHeight/4,
        width: SizeConfig.screenWidth,
        child: Center(child: Image.asset('assets/images/logo.png',color: white,width: SizeConfig.screenWidth/3,height: SizeConfig.screenWidth/4,))
    );
  }

但是,每次我尝试打开抽屉时都会出现此错误:

Incorrect use of ParentDataWidget.

The ParentDataWidget Flexible(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type ParentData.

Usually, this means that the Flexible widget has the wrong ancestor RenderObjectWidget. Typically, Flexible widgets are placed directly inside Flex widgets.
The offending Flexible is currently placed inside a _InkFeatures widget.

0 个答案:

没有答案