E/flutter(3345):[错误:flutter/lib/ui/ui_dart_state.cc(177)] 未处理的异常:FormatException:意外字符(在字符 1)

时间:2021-01-20 20:44:29

标签: flutter

有人可以帮我解决这个我正在尝试处理我的颤振应用程序的问题吗?这是我得到的错误:

E/flutter ( 3345): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
E/flutter ( 3345): ^
E/flutter ( 3345): 
E/flutter ( 3345): #0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1404:5)
E/flutter ( 3345): #1      _ChunkedJsonParser.parseNumber (dart:convert-patch/convert_patch.dart:1271:9)
E/flutter ( 3345): #2      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:936:22)
E/flutter ( 3345): #3      _parseJson (dart:convert-patch/convert_patch.dart:40:10)
E/flutter ( 3345): #4      JsonDecoder.convert (dart:convert/json.dart:505:36)
E/flutter ( 3345): #5      JsonCodec.decode (dart:convert/json.dart:156:41)
E/flutter ( 3345): #6      _RecuperaPasswordState.resetPassword (package:abbiamounposto1/RecuperaPassword.dart:49:21)
E/flutter ( 3345): <asynchronous suspension>
E/flutter ( 3345): #7      _RecuperaPasswordState.build.<anonymous closure> (package:abbiamounposto1/RecuperaPassword.dart:127:40)
E/flutter ( 3345): #8      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
E/flutter ( 3345): #9      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
E/flutter ( 3345): #10     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
E/flutter ( 3345): #11     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
E/flutter ( 3345): #12     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
E/flutter ( 3345): #13     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:259:7)
E/flutter ( 3345): #14     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
E/flutter ( 3345): #15     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:362:20)
E/flutter ( 3345): #16     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22)
E/flutter ( 3345): #17     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11)
E/flutter ( 3345): #18     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7)
E/flutter ( 3345): #19     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7)
E/flutter ( 3345): #20     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7)
E/flutter ( 3345): #21     _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter ( 3345): #22     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 3345): #23     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 3345): #24     _invoke1 (dart:ui/hooks.dart:265:10)
E/flutter ( 3345): #25     _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
E/flutter ( 3345): 

代码如下:

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:http/http.dart' as http;
import 'package:mailer/mailer.dart';
import 'package:mailer/smtp_server.dart';

class RecuperaPassword extends StatefulWidget{
 @override
 _RecuperaPasswordState createState() => new _RecuperaPasswordState();
}

class _RecuperaPasswordState extends State<RecuperaPassword> {

 TextEditingController user = TextEditingController();


 bool verifyButton = false;
 String verifyLink;

 Future checkUser()async{
   var response = await http.post('https://abbiamounposto.altervista.org/flutter-forget-pass-recover-tutorial/check.php',
   body: {
     "Matricola": user.text,
   }
   );

   var link = json.decode(response.body);
   if (link=="INVALIDUSER"){
     Fluttertoast.showToast(msg: 'Questo utente non è nel nostro database',
     gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 3);

   }else{
     setState(() {
       verifyLink = link;
       verifyButton = true;
     });
     Fluttertoast.showToast(msg: 'Clicka sul Pulsante di Verifica ',
         gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 3);

   }
   print(link);
 }

 int newPass = 0;
 Future resetPassword() async{
   var response = await http.post(verifyLink);
   var link = json.decode(response.body);
   setState(() {
     newPass = link;
   });
   print(link);
   Fluttertoast.showToast(msg: 'La tua Password è stata resettata : $newPass',
       gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 3);
 }


 @override
 Widget build(BuildContext context) {
   return Scaffold(
       body: SingleChildScrollView( child: Column(
         mainAxisSize: MainAxisSize.min,
           crossAxisAlignment: CrossAxisAlignment.start,
           children: <Widget>[
             Container(
               margin: EdgeInsets.only(right: 70.0, left: 70.0, top:20),
               padding: EdgeInsets.only(top: 5.0, left: 20.0, right: 20.0),
               child: Stack(
                 children:<Widget> [
                   LogoImageAsset(),
                 ],
               ),
             ),
             Container(
                 child: Stack(
                   children:<Widget> [
                     Container(
                       alignment: Alignment.bottomCenter,
                       child: Text(
                           'RECUPERA PASSWORD',
                           style: GoogleFonts.montserrat(
                             textStyle: TextStyle(color:Color(0xFF182D54)),
                             fontSize: 20.0,
                             fontWeight: FontWeight.w800,)
                       ),
                     ),
                     Container(
                         padding: EdgeInsets.only(top: 70.0, left: 20.0, right: 20.0),
                         child: Column(
                           children: <Widget> [
                             TextField(
                               controller: user,
                               decoration: InputDecoration(
                                   labelText: 'Matricola Utente',
                                   labelStyle: GoogleFonts.montserrat(
                                     textStyle: TextStyle(color: Color(0xFF182D54)),
                                     fontSize: 17.0,
                                     fontWeight: FontWeight.w700,),
                                   focusedBorder: UnderlineInputBorder(
                                       borderSide: BorderSide(color: Color(0xFF182D54)))),
                             ),
                             SizedBox(height: 50.0),
                             Container(
                               height: 40.0,
                               child: MaterialButton(
                                 onPressed: (){
                                   checkUser();
                                 },
                                   color: Color(0xFF182D54),
                                   elevation: 7.0,
                                   shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)

                               ),
                                   child: Text(
                                   'RESET PASSWORD',
                                   style: GoogleFonts.montserrat(
                                     textStyle: TextStyle(color: Colors.white),
                                     fontSize: 20.0,
                                     fontWeight: FontWeight.w700,)
                                   )),


                                 ),
                             verifyButton ? MaterialButton(
                                    onPressed: (){
                                      resetPassword();
                                       },
                                   child: Text('VERIFICA',)
                             ): Container(),

                             SizedBox( height: 40.0),
                             Container(
                               height: 40.0,
                               child: MaterialButton(
                                     onPressed: () {
                                       Navigator.pushNamed(context, '/homepage');
                                     },
                                     shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                                     color: Color(0xFF182D54),
                                     elevation: 7.0,
                                     child: Center(
                                         child: Text(
                                             'INDIETRO',
                                             style: GoogleFonts.montserrat(
                                               textStyle: TextStyle(color: Colors.white),
                                               fontSize: 20.0,
                                               fontWeight: FontWeight.w700,))),
                                   )),

                           ],
                         )
                     ),
                   ],
                 )
             )
           ] )
       )
   );
 }
}

这是我制作重置密码页面所需的代码,它也链接到一个php文件。我只上传了我认为可能导致错误的部分代码...请我真的需要解决这个问题!

另外,有人知道如何将 Flutter 应用程序与在线数据库连接起来吗?或者有没有人有教程给我看,我们正在用flutter开发这个新应用,但对这个世界来说也是非常新的,所以如果你能帮助我们,我们将不胜感激!!!

0 个答案:

没有答案