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

When do we use double.INFINITY ?

Câu trả lời

Here is a concise answer to your interview question about when to use double.INFINITY in Flutter:

When to Use double.INFINITY in Flutter

In Flutter, double.INFINITY is a constant that represents positive infinity. It is useful in a few specific scenarios:

1. Setting Constraints with Infinite Size

When creating constraints for a widget, such as with BoxConstraints, you can use double.INFINITY to indicate that the constraint has no limit in a particular dimension. For example:

dart Copy
BoxConstraints(
  minWidth: 100,
  maxWidth: double.INFINITY,
  minHeight: 50,
  maxHeight: double.INFINITY,
)

This sets a minimum width of 100 and a minimum height of 50, but allows the widget to expand infinitely in width and height.

2. Representing Unbounded Values

You can use double.INFINITY to represent values th...

middle

middle

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

senior

When would you use App state or Ephemeral state over another?

junior

How many types of widgets are there in Flutter?

senior

What's the difference between async and async* in Dart?

Bình luận

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

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