提问者:小点点

扑动错误:有人能帮我吗?


**嗨,伙计们。 这周我在写代码,五天前我遇到了一个错误。 我解决不了这个问题,因为我对这门语言不熟悉。 有人帮帮我吗?

忽略(仅用于填充文本):345678IUJHGTYHGFTYHT5TYGDHEUT9ETAERGJGJHE5YUQ9IYE5IGAERGJGJGDHEUT9TU59T4U69569569GVNGFE5TU59TU69569GVNGFE5TU59TI965968OGKSREWWR32423.。。。。。。。。

错误:

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']);
                    },
                ),
              ],
            ),
          ),
        );
      }
    }

共1个答案

匿名用户

您尝试调用空长度,更新代码,在调用长度的地方添加party