Walter M
Walter M

Reputation: 5543

What is the Offset class?

Can someone please explain the Offset class in flutter:

  1. What is it and its purpose?
  2. What is the meaning of dx and dy? (does it mean delta x and delta y?

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

Answers (2)

Amir Hossein Mirzaei
Amir Hossein Mirzaei

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

Cybdom
Cybdom

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

Related Questions