myObject?.someProperty?.someMethod()
The preceding code returns null (and never calls someMethod()) if either myObject or myObject.someProperty is
null.
Q26: What is the difference between double.INFINITY and MediaQuery?
GET START
Senior Top 68 Flutter Interview Questions Flutter 68
Answer
The difference can be summarised into:
I want to be as big as my parent allows (double.INFINITY)
I want to be as big as the screen (MediaQuery).
Usually, you'll want to use double.infinity, but it's not always possible. Some Widgets allow their children to be
as big as they want to be (Column, ListView, OverflowBox...). In that situation using double.infinity creates a
paradox:
The parent allows any size
The child wants the biggest size allowed by the parent
Q27: Explain Stateful Widget Lifecycle in details
GET START
Expert Top 68 Flutter Interview Questions Flutter 68
Answer
A stateful widget has the following lifecycle stages:
createState()
mounted == true
initState()
didChangeDependencies()
build()
didUpdateWidget()
setState()
deactivate()
dispose()
mounted == false
createState()
When Flutter is instructed to build a StatefulWidget, it immediately calls createState(). This method must
exist. A StatefulWidget rarely needs to be more complicated than this.
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
}
mounted is true
Dostları ilə paylaş: