Android 颤振应用程序返回“;吸气剂';长度';被调用时为null“;
这周我在写代码时出错了。我不能解决这个问题,因为我不熟悉这门语言 错误:Android 颤振应用程序返回“;吸气剂';长度';被调用时为null“;,android,flutter,android-appwidget,flutter-desktop,Android,Flutter,Android Appwidget,Flutter Desktop,这周我在写代码时出错了。我不能解决这个问题,因为我不熟悉这门语言 错误: The following NoSuchMethodError was thrown while handling a gesture: The getter 'length' was called on null. Receiver: null Tried calling: length 0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5) 1 _
The following NoSuchMethodError was thrown while handling a gesture: The getter 'length' was called
on null. Receiver: null Tried calling: length
0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
1 _parseJson (dart:convert-patch/convert_patch.dart:30:28)
2 JsonDecoder.convert (dart:convert/json.dart:505:36)
3 JsonCodec.decode (dart:convert/json.dart:153:41)
4 __HomeState.build. (package:fiveo/main.dart:83:30)
我的代码:
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:async/async.dart';
import 'package:http/http.dart' as http;
import 'package:convert/convert.dart';
var nome1 = TextEditingController();
var sobrenome1 = TextEditingController();
var nome = nome1.value;
var sobrenome = sobrenome1.value;
String responsebody;
dynamic url = "https://completecriminalchecks.com/api/json/?firstname=$nome&lastname=$sobrenome&apikey=v11x15lmnyk7b40pes6ug3";
Future<void> main() async {
http.Response response = await http.get(url);
responsebody = response.body;
String dadosPessoa() {
print(json.decode(responsebody)['object']['response']);
}
runApp(MaterialApp(
home: _Home(),
));
}
class _Home extends StatefulWidget {
@override
__HomeState createState() => __HomeState();
}
class __HomeState extends State<_Home> {
String get resultado => null;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"FIVE-0"),
),
body:
Form(
child:
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
TextFormField(
controller: nome1,
decoration: const InputDecoration(
hintText: "Nome do suspeito:",
),
validator: (value) {
if (value.isEmpty) {
return 'Digite o nome sugeito';
}
return null;
},
),
TextFormField(
controller: sobrenome1,
decoration: const InputDecoration(
hintText: "Nome do suspeito:",
),
validator: (value) {
if (value.isEmpty) {
return 'Digite o nome sugeito';
}
return null;
},
),
RaisedButton(
onPressed: () {
return (json.decode(responsebody)['object']['response']);
},
),
],
),
),
);
}
}
导入'dart:convert';
进口“包装:颤振/cupertino.dart”;
进口“包装:颤振/材料.省道”;
导入“包:async/async.dart”;
将“package:http/http.dart”导入为http;
导入“package:convert/convert.dart”;
var nome1=TextEditingController();
var sobrenome1=TextEditingController();
var nome=nome1.0的数值;
var sobrenome=sobrenome1.value;
字符串响应体;
动态url=”https://completecriminalchecks.com/api/json/?firstname=$nome&lastname=$sobrenome&apikey=v11x15lmnyk7b40pes6ug3”;
Future main()异步{
http.Response-Response=等待http.get(url);
responsebody=response.body;
字符串dadosPessoa(){
打印(json.decode(responsebody)['object']['response']);
}
runApp(材料应用程序)(
主页:_home(),
));
}
类_Home扩展StatefulWidget{
@凌驾
__HomeState createState();
}
类uu HomeState扩展状态{
字符串get resultado=>null;
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
标题:正文(
“五比零”),
),
正文:
形式(
儿童:
纵队(
crossAxisAlignment:crossAxisAlignment.center,
儿童:[
TextFormField(
控制员:nome1,,
装饰:常量输入装饰(
hintText:“我不怀疑:”,
),
验证器:(值){
if(value.isEmpty){
返回“Digite o nome sugeito”;
}
返回null;
},
),
TextFormField(
控制员:sobrenome1,
装饰:常量输入装饰(
hintText:“我不怀疑:”,
),
验证器:(值){
if(value.isEmpty){
返回“Digite o nome sugeito”;
}
返回null;
},
),
升起的按钮(
已按下:(){
返回(json.decode(responsebody)['object']['response']);
},
),
],
),
),
);
}
}
可能会删除:
var nome = nome1.value;
var sobrenome = sobrenome1.value;
会有帮助吗?我不确定,但希望它能起作用 欢迎..删除不需要的文本并解释您的查询。请参阅此链接以询问最佳问题
https://stackoverflow.com/help/how-to-ask