Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 未处理的异常:FormatException:不是有效的链接本地地址,但包含%_Flutter_Dart - Fatal编程技术网

Flutter 未处理的异常:FormatException:不是有效的链接本地地址,但包含%

Flutter 未处理的异常:FormatException:不是有效的链接本地地址,但包含%,flutter,dart,Flutter,Dart,我编写了一个测试函数,它允许我测试一个链接,并在服务器响应时向我敬酒。我使用http库进行测试。起初,一切都很好,但从我的SDK崩溃的那一天起(但我能够按照android studio idea给出的指示进行恢复)。在这次事件之后,当我编译我的应用程序并再次测试我的链接时,我得到了一个格式异常错误。当我打印editingController检索到的字段时,它与输入的字段完全相同。当我点击按钮时,测试%20被添加到我的字段末尾,我不知道为什么,它使我的链接无效。怎么办 在我的字段中输入的链接是te

我编写了一个测试函数,它允许我测试一个链接,并在服务器响应时向我敬酒。我使用http库进行测试。起初,一切都很好,但从我的SDK崩溃的那一天起(但我能够按照android studio idea给出的指示进行恢复)。在这次事件之后,当我编译我的应用程序并再次测试我的链接时,我得到了一个格式异常错误。当我打印editingController检索到的字段时,它与输入的字段完全相同。当我点击按钮时,测试%20被添加到我的字段末尾,我不知道为什么,它使我的链接无效。怎么办

在我的字段中输入的链接是test.sellams.com

E/flutter (11454): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: FormatException: test.sellams.com%20 is not a valid link-local address but contains %. Scope id should be used as part of link-local address. (at character 17)
E/flutter (11454): test.sellams.com%20
我的链接测试功能


ToastLink() async {
          try {
            _checkInternetConnection();
            Map result;
          String  url = linkController.text;
          print(url);
          String link ="http://"+url;
            http.Response response = await http.post(
                link);
           // result = json.decode(response.body);
              final int statusCode = response.statusCode;
              if (statusCode == 200) {
                Fluttertoast.showToast(
                    msg: " CE LIEN EST VALIDE ",
                    toastLength: Toast.LENGTH_LONG,
                    backgroundColor: Colors.green,
                    textColor: Colors.white
                );
                setState(() {
                  SaveUrlPreferences(url);
                });


              }
              else{
                Fluttertoast.showToast(
                    msg: " CE LIEN EST INVALIDE ",
                    toastLength: Toast.LENGTH_LONG,
                    backgroundColor: Colors.red,
                    textColor: Colors.white);


                 // Future.delayed(const Duration(milliseconds: 2000));
              }

链接字段


 new TextField(
               controller: linkController,
               focusNode: myFocusNodeLink,
               textInputAction: TextInputAction.next,
               onSubmitted: (term) {
                 _fieldFocusChange(context, myFocusNodeLink, myFocusNodeUserName);
               },
               decoration: InputDecoration(
                 errorText: _validate ? 'Le champ lien est obligatoire' : null,
                 hintText: "Entrez le lien",
                 hintStyle: TextStyle(
                   color: Theme.of(context).primaryColor,
                   fontSize: 16.0,
                 ),
                 border: OutlineInputBorder(
                   borderRadius: BorderRadius.circular(15.0),
                 ),
                 prefixIcon: Icon(Icons.attachment),
               ),
             ),
             SizedBox(height: 15.0,),


尝试更改以下行:


String link=“http://”+url.trim()

尝试更改以下行:

String link=“http://”+url.trim()