CoordinatesToAlignment class
Converts the global position at which the pointer contacted the screen into Alignment. Call the convert() method is required to finish converting.
It uses tap details provided by GestureDetector or another GestureRecognizerFactory.
Typical usage is as follows:
GestureDetector(
child: Container(
width: 50.0,
height: 50.0,
color: Colors.blue,
),
onTapUp: (TapUpDetails tapDetails) {
final _converter = CoordinatesToAlignment(
point: tapDetails.globalPosition,
screenSize: MediaQuery.of(context).size,
);
final _alignment = _converter.convert();
print('Coordinates have been converted into Alignment');
print('Alignment.x = ' + _alignment.x?.toString());
print('Alignment.y = ' + _alignment.y?.toString());
},
);
Constructors
- CoordinatesToAlignment({required Offset point, required Size screenSize})
-
Creates a CoordinatesToAlignment
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- point → Offset
-
The global position at which the pointer contacted the screen.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- screenSize → Size
-
The screen size.
final
Methods
-
convert(
) → Alignment - Converts the global position at which the pointer contacted the screen into Alignment.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited