DolDurma
DolDurma

Reputation: 17331

Flutter what is the difference between creating state in different manner?

In Flutter, we can use any of them to create our StatefulWidget. Like:

1:

class MyClass extends StatefulWidget{
  @override
  State<StatefulWidget> createState() => MyClassState();
}

2:

class MyClass extends StatefulWidget{
  @override
  State<MyClass> createState() => MyClassState();
}

3:

class MyClass extends StatefulWidget{
  @override
  MyClassState createState() => MyClassState();
}

What's the difference between them?

Upvotes: 2

Views: 62

Answers (1)

Mazin Ibrahim
Mazin Ibrahim

Reputation: 7889

There is no difference at all between them, because in all of these snippets createState type is either State<StatefulWidget> or one of its subclasses. Which correctly overrides createState.

Upvotes: 2

Related Questions