flutter 所有者._debugCurrentBuildTarget ==这不是真的

aiazj4mn  于 2022-11-17  发布在  Flutter
关注(0)|答案(1)|浏览(108)

代码没有问题,但当我运行
我得到错误owner._debugCurrentBuildTarget ==这不是真的我如何解决这个问题

class HomePage  extends StatelessWidget{
  @override
  HomePageState createState() => HomePageState();

  @override
  dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}

class HomePageState extends State{

  late int first, second;
  late String islem;
  late String result, sonuc;
7gcisfzg

7gcisfzg1#

我认为您缺少StatefulWidget,请尝试

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  late int first, second;
  late String islem;
  late String result, sonuc;
  @override
  void initState() {
    super.initState();
    first = 1;
    second = 2;
    islem = "islem";
    result = "A";
    sonuc = "sonuc";
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

相关问题