颤动的意外错误

发布于 2025-02-08 00:51:20 字数 13832 浏览 2 评论 0原文

我对陷入错误,错误和解决问题的圈子的整个事情并不是新手。 过去几周我一直面临的事实是,该代码在另一台笔记本电脑中起作用,也许是在别人的项目中,但我遇到了错误,尽管我检查了并已经成功地运行了几次过程。 它已经发布了,这些错误不存在。 我们确实有一个无效检查器:

child: SingleChildScrollView(
                    child:  isLoading
                        ?  Column(

知道加载是错误的 我经营Android Studio。

ps下面的一些代码感到缺少,因为它具有有价值的数据,或者它的时间比已经更长

 Widget build(BuildContext context) {
    return DefaultTabController(
      length: 1,
      child: MaterialApp(
        theme: ThemeData(fontFamily: 'Harmattan',),
        home: Scaffold(
            key: _scaffoldKey,
            appBar: AppBar(
              actions: [
                IconButton(onPressed: (){
                  Navigator.push(
                      context,
                      new MaterialPageRoute(
                          builder: (context) => MaintenanceDataTypesByDriver()));
                }, icon: Icon(Icons.view_headline_sharp,size: 40,),)
              ],

              title: Center(child: Text(
                'enter',
                style: TextStyle(fontSize: 25, color: Colors.white),
              ),),
              leading: Builder(
                builder: (BuildContext context) {
                  return IconButton(
                    icon: const Icon(
                      Icons.arrow_back_rounded,
                      size: 40,
                      color: Colors.white,
                    ),
                    onPressed: () {
                      //Navigator.pushNamed(context, mainScreen.id);
                      Navigator.push(
                          context,
                          new MaterialPageRoute(
                              builder: (context) => maintenance_screen()));
                    },
                  );
                },
              ),
            ),
            body: TabBarView(
              children: [
                Center(
                  child: SingleChildScrollView(
                    child:  isLoading
                        ?  Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        new CircularProgressIndicator(),
                        new Text("   اplease hold..  ")
                      ],
                    )
                        : new Column(
                      //crossAxisAlignment: CrossAxisAlignment.stretch,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        SizedBox(height: 0),
                        Center(
                          child: Text(
                            " choose an option",
                            style: TextStyle(fontSize: 25,),
                          ),
                        ),
                        SizedBox(height: 5,),
                        // Operations Types Api List New / 
                        Container(
                          height: 75,
                          width: 400,
                          decoration: BoxDecoration(
                              color: Colors.blue.withOpacity(0.35), // border color
                              borderRadius: BorderRadius.all(Radius.circular(20))
                          ),
                          child: Center(
                            child: DropdownButtonHideUnderline(
                              child: DropdownButton(
                     
                                  style: TextStyle(
                                      fontSize: 20.0,
                                      fontWeight: FontWeight.bold
                                  ),),
                           .........
                                }).toList(),
                                onChanged: (String? newVal) {
                                  setState(() {
                                   print(faultReportingName1.toString());
                                  });
                                },
                                value: faultReportingName,                 //pasing the default id that has to be viewed... //i havnt used something ... //you can place some (id)
                              ),
                            ),
                          ),
                        ),
                        SizedBox(height: 5),
                        Center(
                          child: Text(
                            "press here",
                            style: TextStyle(fontSize: 25,),
                          ),
                        ),
                        SizedBox(height: 5,),
                        // Fault Locations  Api List New
                        Container(
                          height: 75,
                          width: 400,
                          decoration: BoxDecoration(
                              color: Colors.blue.withOpacity(0.35), // border color
                              borderRadius: BorderRadius.all(Radius.circular(20))
                          ),
                          child: Center(
                            child: DropdownButtonHideUnderline(
                              child: DropdownButton(
                                hint: Text("اpress here",
                                  style: TextStyle(
                                      fontSize: 20.0,
                                      fontWeight: FontWeight.bold
                                  ),),
                             .....
                                          style: const TextStyle(
                                              fontSize: 20.0,
                                              fontWeight: FontWeight.bold
                                          ),
                                          textAlign : TextAlign.end,
                                        ),
                               ...........
},
                                value: faultLocationsName,                 //pasing the default id that has to be viewed... //i havnt used something ... //you can place some (id)
                              ),
                            ),
                          ),
                        ),
                        SizedBox(height: 10),
                        Center(
                          child: Text(
                            "    date",
                            style: TextStyle(fontSize: 25),

                          ),
                        ),
                        // 
                        Container(
                          width: 300,
                          height: 75,
                          child: TextField(
                            style: TextStyle(color: Colors.black, fontSize: 20),
                            onTap: () {
                              FocusScope.of(context).requestFocus(new FocusNode());
                              showDatePicker(context: context, initialDate:  DateTime.now(),                            textAlign: TextAlign.center,
                            decoration: InputDecoration(
                              errorStyle: TextStyle(height: 0.1),
                              errorText: _validateStartingDateController ? 'date' : null,
                              alignLabelWithHint: true,
                              //labelText: 'Qty',
                              hintText: '$faultDate1' ,
                              hintStyle: TextStyle(),
                              border: OutlineInputBorder(
                                borderSide:
                                BorderSide(color: Colors.yellow,
                                    /* 0xfffdbd2a*/width: 20),
                                borderRadius: BorderRadius.all(Radius.circular(15.0)),
                                //borderRadius: BorderRadius.circular(15),
                              ),
                            ),
                            obscureText: false,
                            //controller: myController,
                          ),
                        ),
                        // 
                        Center(
                          child: Text(
                            "maintenance ",
                            style: TextStyle(fontSize: 25),

                          ),
                        ),
                        SizedBox(height: 0),
                        TextField(
                          style: TextStyle(fontSize: 20),
                          keyboardType: TextInputType.number,
                          //inputFormatters: [FilteringTextInputFormatter.digitsOnly],
                          controller: opCostController,
                          textAlign: TextAlign.end,
                          decoration: InputDecoration(
                            errorText: _valueValidate ? 'required' : null,
                            alignLabelWithHint: true,
                            //labelText: 'Qty',
                            hintText: 'IQD ',
                            hintStyle: TextStyle(),
                            border: OutlineInputBorder(
                              borderSide:
                              BorderSide(color: Color(0xfffdbd2a), width: 20),
                              borderRadius:
                              BorderRadius.all(Radius.circular(15.0)),
                              //borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          obscureText: false,
                          //controller: myController,
                        ),
                        SizedBox(height: 0),
                        Center(
                          child: Text(
                            "notes",
                            style: TextStyle(fontSize: 25),
                          ),
                        ),
                        SizedBox(height: 0),
                        TextField(
                          style: TextStyle(fontSize: 20),
                          controller: notesController,
                          textAlign: TextAlign.end,
                          decoration: InputDecoration(
                            errorStyle: TextStyle(height: 1),
                            alignLabelWithHint: true,                            hintStyle: TextStyle(),
                            border: OutlineInputBorder(
                              borderSide:
                              BorderSide(color: Color(0xfffdbd2a), width: 20),
                              borderRadius:
                              BorderRadius.all(Radius.circular(15.0)),
                              //borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          obscureText: false,
                          //controller: myController,
                        ),
                 
                        SizedBox(height: 5),
                        Center(
                          child: _file == null ? Text('') :
                          Container(
                            height: 310,
                            margin: EdgeInsets.all(10),
                            decoration: BoxDecoration(
                              image: DecorationImage(
                                fit: BoxFit.fill,
                                image: FileImage(_file!),
                              ),
                              borderRadius: BorderRadius.circular(10),
                            ),
                            //child: Image.asset('images/Logistic.jpg'),
                          ),
                        ),
                        Container(
                          height: 50,
                          width: 200,
                          child: ElevatedButton(
                            //style: ElevatedButton.styleFrom(side: BorderSide(width: 1,style: BorderStyle.solid),
                            style: ButtonStyle(
                                shape: MaterialStateProperty.all<
                                    RoundedRectangleBorder>(
                                    RoundedRectangleBorder(
                                        borderRadius: BorderRadius.circular(50.0),
                                        side: BorderSide(color: Colors.white)))),
                            //style: ButtonStyle(shape: OutlinedBorder()),
                            child: Text(
                              'save',
                              style: TextStyle(color: Colors.white, fontSize: 20),
                            ),
                            onPressed: () {
                              //if(isLoading)return;
                              setState(() {
                              
                              double opCost = double.parse(opCostController.text.trim());
                              String date = faultDateController.text;
                              int faultLocID = int.parse(faultLocationsName1!.trim());
                              int faultRepID = int.parse(faultReportingName1!.trim());
                              String notes = notesController.text.trim();
                              if(opCost.isNaN || faultReportingName1=='' || faultLocationsName1=='' ||date =='')
                              {
                                print('empty');
                                return;


                              }
                              else{
                                upload();

i am no newbie to the whole thing of being in a circle of errors, bugs and problem solving.
what i have been facing for the last few weeks is the fact that the code works in another laptop, maybe at someone else's project but i get the errors like it doesn't work although i checked and have run the process successfully a few times before.
it had posted, and those errors didn't exist.
we do have a null checker:

child: SingleChildScrollView(
                    child:  isLoading
                        ?  Column(

knowing that is Loading is false
and i run android studio.

enter image description here

ps some of the code below feels missing because it has valuable data , and or it would have been longer than what it already is

 Widget build(BuildContext context) {
    return DefaultTabController(
      length: 1,
      child: MaterialApp(
        theme: ThemeData(fontFamily: 'Harmattan',),
        home: Scaffold(
            key: _scaffoldKey,
            appBar: AppBar(
              actions: [
                IconButton(onPressed: (){
                  Navigator.push(
                      context,
                      new MaterialPageRoute(
                          builder: (context) => MaintenanceDataTypesByDriver()));
                }, icon: Icon(Icons.view_headline_sharp,size: 40,),)
              ],

              title: Center(child: Text(
                'enter',
                style: TextStyle(fontSize: 25, color: Colors.white),
              ),),
              leading: Builder(
                builder: (BuildContext context) {
                  return IconButton(
                    icon: const Icon(
                      Icons.arrow_back_rounded,
                      size: 40,
                      color: Colors.white,
                    ),
                    onPressed: () {
                      //Navigator.pushNamed(context, mainScreen.id);
                      Navigator.push(
                          context,
                          new MaterialPageRoute(
                              builder: (context) => maintenance_screen()));
                    },
                  );
                },
              ),
            ),
            body: TabBarView(
              children: [
                Center(
                  child: SingleChildScrollView(
                    child:  isLoading
                        ?  Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        new CircularProgressIndicator(),
                        new Text("   اplease hold..  ")
                      ],
                    )
                        : new Column(
                      //crossAxisAlignment: CrossAxisAlignment.stretch,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        SizedBox(height: 0),
                        Center(
                          child: Text(
                            " choose an option",
                            style: TextStyle(fontSize: 25,),
                          ),
                        ),
                        SizedBox(height: 5,),
                        // Operations Types Api List New / 
                        Container(
                          height: 75,
                          width: 400,
                          decoration: BoxDecoration(
                              color: Colors.blue.withOpacity(0.35), // border color
                              borderRadius: BorderRadius.all(Radius.circular(20))
                          ),
                          child: Center(
                            child: DropdownButtonHideUnderline(
                              child: DropdownButton(
                     
                                  style: TextStyle(
                                      fontSize: 20.0,
                                      fontWeight: FontWeight.bold
                                  ),),
                           .........
                                }).toList(),
                                onChanged: (String? newVal) {
                                  setState(() {
                                   print(faultReportingName1.toString());
                                  });
                                },
                                value: faultReportingName,                 //pasing the default id that has to be viewed... //i havnt used something ... //you can place some (id)
                              ),
                            ),
                          ),
                        ),
                        SizedBox(height: 5),
                        Center(
                          child: Text(
                            "press here",
                            style: TextStyle(fontSize: 25,),
                          ),
                        ),
                        SizedBox(height: 5,),
                        // Fault Locations  Api List New
                        Container(
                          height: 75,
                          width: 400,
                          decoration: BoxDecoration(
                              color: Colors.blue.withOpacity(0.35), // border color
                              borderRadius: BorderRadius.all(Radius.circular(20))
                          ),
                          child: Center(
                            child: DropdownButtonHideUnderline(
                              child: DropdownButton(
                                hint: Text("اpress here",
                                  style: TextStyle(
                                      fontSize: 20.0,
                                      fontWeight: FontWeight.bold
                                  ),),
                             .....
                                          style: const TextStyle(
                                              fontSize: 20.0,
                                              fontWeight: FontWeight.bold
                                          ),
                                          textAlign : TextAlign.end,
                                        ),
                               ...........
},
                                value: faultLocationsName,                 //pasing the default id that has to be viewed... //i havnt used something ... //you can place some (id)
                              ),
                            ),
                          ),
                        ),
                        SizedBox(height: 10),
                        Center(
                          child: Text(
                            "    date",
                            style: TextStyle(fontSize: 25),

                          ),
                        ),
                        // 
                        Container(
                          width: 300,
                          height: 75,
                          child: TextField(
                            style: TextStyle(color: Colors.black, fontSize: 20),
                            onTap: () {
                              FocusScope.of(context).requestFocus(new FocusNode());
                              showDatePicker(context: context, initialDate:  DateTime.now(),                            textAlign: TextAlign.center,
                            decoration: InputDecoration(
                              errorStyle: TextStyle(height: 0.1),
                              errorText: _validateStartingDateController ? 'date' : null,
                              alignLabelWithHint: true,
                              //labelText: 'Qty',
                              hintText: '$faultDate1' ,
                              hintStyle: TextStyle(),
                              border: OutlineInputBorder(
                                borderSide:
                                BorderSide(color: Colors.yellow,
                                    /* 0xfffdbd2a*/width: 20),
                                borderRadius: BorderRadius.all(Radius.circular(15.0)),
                                //borderRadius: BorderRadius.circular(15),
                              ),
                            ),
                            obscureText: false,
                            //controller: myController,
                          ),
                        ),
                        // 
                        Center(
                          child: Text(
                            "maintenance ",
                            style: TextStyle(fontSize: 25),

                          ),
                        ),
                        SizedBox(height: 0),
                        TextField(
                          style: TextStyle(fontSize: 20),
                          keyboardType: TextInputType.number,
                          //inputFormatters: [FilteringTextInputFormatter.digitsOnly],
                          controller: opCostController,
                          textAlign: TextAlign.end,
                          decoration: InputDecoration(
                            errorText: _valueValidate ? 'required' : null,
                            alignLabelWithHint: true,
                            //labelText: 'Qty',
                            hintText: 'IQD ',
                            hintStyle: TextStyle(),
                            border: OutlineInputBorder(
                              borderSide:
                              BorderSide(color: Color(0xfffdbd2a), width: 20),
                              borderRadius:
                              BorderRadius.all(Radius.circular(15.0)),
                              //borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          obscureText: false,
                          //controller: myController,
                        ),
                        SizedBox(height: 0),
                        Center(
                          child: Text(
                            "notes",
                            style: TextStyle(fontSize: 25),
                          ),
                        ),
                        SizedBox(height: 0),
                        TextField(
                          style: TextStyle(fontSize: 20),
                          controller: notesController,
                          textAlign: TextAlign.end,
                          decoration: InputDecoration(
                            errorStyle: TextStyle(height: 1),
                            alignLabelWithHint: true,                            hintStyle: TextStyle(),
                            border: OutlineInputBorder(
                              borderSide:
                              BorderSide(color: Color(0xfffdbd2a), width: 20),
                              borderRadius:
                              BorderRadius.all(Radius.circular(15.0)),
                              //borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          obscureText: false,
                          //controller: myController,
                        ),
                 
                        SizedBox(height: 5),
                        Center(
                          child: _file == null ? Text('') :
                          Container(
                            height: 310,
                            margin: EdgeInsets.all(10),
                            decoration: BoxDecoration(
                              image: DecorationImage(
                                fit: BoxFit.fill,
                                image: FileImage(_file!),
                              ),
                              borderRadius: BorderRadius.circular(10),
                            ),
                            //child: Image.asset('images/Logistic.jpg'),
                          ),
                        ),
                        Container(
                          height: 50,
                          width: 200,
                          child: ElevatedButton(
                            //style: ElevatedButton.styleFrom(side: BorderSide(width: 1,style: BorderStyle.solid),
                            style: ButtonStyle(
                                shape: MaterialStateProperty.all<
                                    RoundedRectangleBorder>(
                                    RoundedRectangleBorder(
                                        borderRadius: BorderRadius.circular(50.0),
                                        side: BorderSide(color: Colors.white)))),
                            //style: ButtonStyle(shape: OutlinedBorder()),
                            child: Text(
                              'save',
                              style: TextStyle(color: Colors.white, fontSize: 20),
                            ),
                            onPressed: () {
                              //if(isLoading)return;
                              setState(() {
                              
                              double opCost = double.parse(opCostController.text.trim());
                              String date = faultDateController.text;
                              int faultLocID = int.parse(faultLocationsName1!.trim());
                              int faultRepID = int.parse(faultReportingName1!.trim());
                              String notes = notesController.text.trim();
                              if(opCost.isNaN || faultReportingName1=='' || faultLocationsName1=='' ||date =='')
                              {
                                print('empty');
                                return;


                              }
                              else{
                                upload();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

子栖 2025-02-15 00:51:20

我认为问题来自您的数据模型类。您的某些字符串值为null。

尝试仔细检查。

I think the problem is coming from your data model class. some of your String values is Null.

Try to check it carefully.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文