0

I got this problem

***> E/flutter (15532): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)]

Unhandled Exception: FormatException: Unexpected character (at character 1) E/flutter (15532):
E/flutter (15532): ^ E/flutter (15532): E/flutter (15532): #0 _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1404:5) E/flutter (15532): #1
_ChunkedJsonParser.parseNumber (dart:convert-patch/convert_patch.dart:1271:9) E/flutter (15532): #2
_ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:936:22) E/flutter (15532): #3
_parseJson (dart:convert-patch/convert_patch.dart:40:10) E/flutter (15532): #4 JsonDecoder.convert (dart:convert/json.dart:506:36) E/flutter (15532): #5 JsonCodec.decode (dart:convert/json.dart:157:41) E/flutter (15532): #6 jsonDecode (dart:convert/json.dart:96:10) E/flutter (15532): #7
_LoginState.login (package:flutter_login/main.dart:35:18) E/flutter (15532): E/flutter (15532):***

this is my code

    void main() {
  HttpOverrides.global = new MyHttpOverrides();
  runApp(MaterialApp(
    home: login(),
  ));
}

class login extends StatefulWidget {
  @override
  _LoginState createState() => _LoginState();
}

class _LoginState extends State<login>{
  var email,password;
  final _key = new GlobalKey<FormState>();
  check(){
    final form = _key.currentState;
    if(form.validate()){
      form.save();
      login();
    }
  }

  login() async{
    final response = await http.post(Uri.parse("link"),
        body: {
      "email" : email,
      "password" : password
    });
    final data = jsonDecode(response.body);
    print(data);
  }

  bool _secureText = false;
  showHide(){
    setState(() {
      _secureText = !_secureText;
    });
  }

can help me? pls

1
  • print response.body Commented May 10, 2021 at 14:24

1 Answer 1

1

Seems to me your Uri parsing is failing since you've passed "link" which is an invalid uri.

This is from the Uri.parse docs:

If the uri string is not valid as a URI or URI reference, a FormatException is thrown.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.