类型 'Null' 不是 'function result' 的类型 'String' 的子类型

type 'Null' is not a subtype of type 'String' of 'function result'

错误:

The following _TypeError was thrown while routing a pointer event:
type 'Null' is not a subtype of type 'String' of 'function result'

When the exception was thrown, this was the stack: 
#0      _Location.file (package:flutter/src/widgets/widget_inspector.dart)
#1      _Location.toJsonMap (package:flutter/src/widgets/widget_inspector.dart:2844:15)
#2      _Location.toJsonMap.<anonymous closure> (package:flutter/src/widgets/widget_inspector.dart:2853:42)
#3      MappedListIterable.elementAt (dart:_internal/iterable.dart:412:31)
#4      ListIterator.moveNext (dart:_internal/iterable.dart:341:26)
...

这是我的代码:

import 'package:flutter/material.dart';

class Signup3 extends StatefulWidget {
  const Signup3({Key? key}) : super(key: key);

  @override
  _Signup3State createState() => _Signup3State();
}

class _Signup3State extends State<Signup3> {
  GlobalKey<FormState> formstate = new GlobalKey<FormState>();

  send() {
    setState(() {
      var formdata = formstate.currentState;

      var fdcurrent = formdata!.validate();
      if (fdcurrent == null) {
        print("sendon");
      } else {
        print("sendoff");
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("signup"),
      ),
      body: Form(
        child: Column(
          children: [
            TextFormField(
              validator: (text) {
                String? f = " ";
                f = text;
                int counter = f!.length;
                if (counter < 3) {
                  return "too small";
                } else {
                  return "valid";
                }
              },
            ),
            ElevatedButton(
              onPressed: send,
              child: Text("submit"),
            ),
          ],
        ),
      ),
    );
  }
}

您必须在表单小部件

中添加key: formstate
body: Form(
        key: formstate,// <--  add this line
        child: Column(
          children: [ ...