forked from firka/flutter
Document that offsets are returned in logical pixels (#33620)
This commit is contained in:
committed by
GitHub
parent
55d98ddd33
commit
3c24c5bdcd
@@ -27,8 +27,11 @@ enum OffsetType {
|
||||
|
||||
EnumIndex<OffsetType> _offsetTypeIndex = EnumIndex<OffsetType>(OffsetType.values);
|
||||
|
||||
/// A Flutter Driver command that return the [offsetType] from the RenderObject
|
||||
/// A Flutter Driver command that returns the [offsetType] from the RenderObject
|
||||
/// identified by [finder].
|
||||
///
|
||||
/// The requested offset is returned in logical pixels, which can be translated
|
||||
/// to device pixels via [Window.devicePixelRatio].
|
||||
class GetOffset extends CommandWithTarget {
|
||||
/// The `finder` looks for an element to get its rect.
|
||||
GetOffset(SerializableFinder finder, this.offsetType, { Duration timeout }) : super(finder, timeout: timeout);
|
||||
@@ -51,14 +54,23 @@ class GetOffset extends CommandWithTarget {
|
||||
}
|
||||
|
||||
/// The result of the [GetRect] command.
|
||||
///
|
||||
/// The offset is provided in logical pixels, which can be translated
|
||||
/// to device pixels via [Window.devicePixelRatio].
|
||||
class GetOffsetResult extends Result {
|
||||
/// Creates a result with the offset defined by [dx] and [dy].
|
||||
const GetOffsetResult({ this.dx = 0.0, this.dy = 0.0});
|
||||
|
||||
/// The x component of the offset.
|
||||
/// The x component of the offset in logical pixels.
|
||||
///
|
||||
/// The value can be translated to device pixels via
|
||||
/// [Window.devicePixelRatio].
|
||||
final double dx;
|
||||
|
||||
/// The y component of the offset.
|
||||
/// The y component of the offset in logical pixels.
|
||||
///
|
||||
/// The value can be translated to device pixels via
|
||||
/// [Window.devicePixelRatio].
|
||||
final double dy;
|
||||
|
||||
/// Deserializes the result from JSON.
|
||||
|
||||
@@ -483,26 +483,41 @@ class FlutterDriver {
|
||||
}
|
||||
|
||||
/// Returns the point at the top left of the widget identified by `finder`.
|
||||
///
|
||||
/// The offset is expressed in logical pixels and can be translated to
|
||||
/// device pixels via [Window.devicePixelRatio].
|
||||
Future<DriverOffset> getTopLeft(SerializableFinder finder, { Duration timeout }) async {
|
||||
return _getOffset(finder, OffsetType.topLeft, timeout: timeout);
|
||||
}
|
||||
|
||||
/// Returns the point at the top right of the widget identified by `finder`.
|
||||
///
|
||||
/// The offset is expressed in logical pixels and can be translated to
|
||||
/// device pixels via [Window.devicePixelRatio].
|
||||
Future<DriverOffset> getTopRight(SerializableFinder finder, { Duration timeout }) async {
|
||||
return _getOffset(finder, OffsetType.topRight, timeout: timeout);
|
||||
}
|
||||
|
||||
/// Returns the point at the bottom left of the widget identified by `finder`.
|
||||
///
|
||||
/// The offset is expressed in logical pixels and can be translated to
|
||||
/// device pixels via [Window.devicePixelRatio].
|
||||
Future<DriverOffset> getBottomLeft(SerializableFinder finder, { Duration timeout }) async {
|
||||
return _getOffset(finder, OffsetType.bottomLeft, timeout: timeout);
|
||||
}
|
||||
|
||||
/// Returns the point at the bottom right of the widget identified by `finder`.
|
||||
///
|
||||
/// The offset is expressed in logical pixels and can be translated to
|
||||
/// device pixels via [Window.devicePixelRatio].
|
||||
Future<DriverOffset> getBottomRight(SerializableFinder finder, { Duration timeout }) async {
|
||||
return _getOffset(finder, OffsetType.bottomRight, timeout: timeout);
|
||||
}
|
||||
|
||||
/// Returns the point at the center of the widget identified by `finder`.
|
||||
///
|
||||
/// The offset is expressed in logical pixels and can be translated to
|
||||
/// device pixels via [Window.devicePixelRatio].
|
||||
Future<DriverOffset> getCenter(SerializableFinder finder, { Duration timeout }) async {
|
||||
return _getOffset(finder, OffsetType.center, timeout: timeout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user