missing concrete implementation of state.build

14,833

Solution 1

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

Solution 2

Check the curly brace that closes the class where the Widget build method is found. You might just have closed it in the wrong place.

This was the case for me.

So make sure your build method is within the curly braces that enclose the class

class _LandingPageState extends State<LandingPage> {
    Widget build(BuildContext context) {
    ...
}

Solution 3

All the Stateful widgets and Stateless widgets should have build method.

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

If you want to use it without build do not extend the class with State, use it like

class YourClassName {
}
Share:
14,833

Related videos on Youtube

SaySomething
Author by

SaySomething

Updated on June 04, 2022

Comments

  • SaySomething
    SaySomething almost 2 years

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

    The first method is the following:

    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?

    Thank you.