Câu hỏi phỏng vấn Flutter
Câu hỏi

What is the difference between ...

Câu trả lời

The main differences between double.infinity and MediaQuery in Flutter are:

  1. double.infinity is used to make a widget occupy the entire available width or height of its parent, regardless of the parent's actual size. It creates a paradox for widgets that have a limited size, like OverflowBox, SizedBox, etc.[1][2]

  2. MediaQuery.of(context).size.width and MediaQuery.of(context).size.height return the actual width and height of the screen or the widget's parent, based on the provided context. This allows the widget to size itself according to the available space.[1][4]

  3. double.infinity is useful for widgets that can grow to fill the available space, like Column, ListView, etc. But it should be avoided for widgets with limited size, as it can lead to layout issues.[1][2]

  4. MediaQuery is commonly used in the build method of widgets to determine the screen size and orientation, and adapt the UI accordingly. It provides a way to create responsive and adaptive...

senior

senior

Gợi ý câu hỏi phỏng vấn

middle

Why is the build() method on State and not Stateful Widget?

senior

Explain async , await in Flutter/Dart?

junior

Does Flutter work like a browser? How is it different from a WebView based application?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào