What is the difference between double.INFINITY and MediaQuery ?
What is the difference between double.INFINITY and MediaQuery ?
The main differences between double.infinity and MediaQuery in Flutter are:
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.
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.
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.
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.