缺少state.build的具体实现 [英] missing concrete implementation of state.build

查看:134
本文介绍了缺少state.build的具体实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Dart中遇到此错误:缺少对"state.build"的具体实现"

I am getting this error in Dart: "Missing concrete implementation of "state.build""

第一种方法如下:

class MyHomePage extends StatefulWidget {
  // String titleInput;
  // String amountInput;
  @override
  MyHomePageState createState() => MyHomePageState();
}

class MyHomePageState extends State<MyHomePage> {
  final List<Transaction> _userTransactions = [
    // Transaction(
    //   id: "t1",
    //   title: "New Shoes",
    //   amount: 69.99,
    //   date: DateTime.now(),
    // ),
    // Transaction(
    //   id: "t2",
    //   title: "Weekly Groceries",
    //   amount: 16.53,
    //   date: DateTime.now(),
    // ),
  ];

有人知道此错误的含义以及如何解决吗?

Does anyone knows what this error means and how to solve it?

谢谢.

推荐答案

您需要向小部件的 State 添加 build 方法,该方法描述您的小部件代表的用户界面部分,例如,(将此添加到 MyHomePageState )

You need to add a build method to the State of your widget, this method describes the part of the user interface represented by your widget, e.g., (add this to the MyHomePageState)

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child:
            Container(
              height: 200,
              width: 100,
              color:  Colors.yellow,
        ),
      ),
    );
  }

这篇关于缺少state.build的具体实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆