Reputation: 5543
Can someone please explain the Offset class in flutter:
The documentation gives no examples and their explanation is vague.
Here is the documentation if you are wondering: Offset Class Documentation Thanks!
Upvotes: 5
Views: 9607
Reputation: 2375
Simply it is a data class to store X and Y coordinates and pass that class data to other classes or functions. In other programming languages this class is called Point, and in dart, it is called Offset. Also, the Offset class gives you some helper methods and operators to work with.
Upvotes: 7
Reputation: 98
One example for the use of Offset is when you add a boxshadow to a container, you can use the Offset to change the "position" of the BoxShadow decoration.
boxShadow: [BoxShadow(
blurRadius: 3.0,
offset: Offset(5,3),
color: MyColors.grey.withOpacity(.5),
)],
Upvotes: 2