Repository: flutter/flutter
File: packages/flutter/lib/src/material/tooltip.dart (Dart)

Code before:
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

import 'colors.dart';
import 'text_theme.dart';
import 'theme.dart';
import 'tooltip_theme.dart';
import 'tooltip_visibility.dart';

/// Signature for when a tooltip is triggered.
typedef TooltipTriggeredCallback = void Function();

/// Signature for computing the position of a tooltip.
///
/// The arguments are:
/// * `target`: The center point of the target widget in the global coordinate system.
/// * `targetSize`: The size of the target widget that triggers the tooltip.
/// * `tooltipSize`: The size of the tooltip itself.
/// * `verticalOffset`: The configured vertical offset.
/// * `preferBelow`: Whether the tooltip prefers to be positioned below the target.
///
/// Returns the offset from the top left of the overlay to the top left of the tooltip.
typedef TooltipPositionDelegate =
    Offset Function({
      required Offset target,
      required Size targetSize,
      required Size tooltipSize,
      required double verticalOffset,
      required bool preferBelow,
    });

/// A special [MouseRegion] that when nested, only the first [_ExclusiveMouseRegion]
/// to be hit in hit-testing order will be added to the BoxHitTestResult (i.e.,
/// child over parent, last sibling over first sibling).
///
/// The [onEnter] method will be called when a mouse pointer enters this
/// [MouseRegion], and there is no other [_ExclusiveMouseRegion]s obstructing
/// this [_ExclusiveMouseRegion] from receiving the events. This includes the
/// case where the mouse cursor stays within the paint bounds of an outer
/// [_ExclusiveMouseRegion], but moves outside of the bounds of the inner
/// [_ExclusiveMouseRegion] that was initially blocking the outer widget.
///
/// Likewise, [onExit] is called when the a mouse pointer moves out of the paint
/// bounds of this widget, or moves into another [_ExclusiveMouseRegion] that
/// overlaps this widget in hit-testing order.
///
/// This widget doesn't affect [MouseRegion]s that aren't [_ExclusiveMouseRegion]s,
/// or other [HitTestTarget]s in the tree.

Review comment (suggestion):
Do you think we might encounter new properties for this delegate in the future? Extending this parameter list will be breaking. What do you think of grouping them into a data class for extensibility? We might call it `TooltipPositionContext` and the delegate will just take one parameter.

Code after:
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

import 'colors.dart';
import 'text_theme.dart';
import 'theme.dart';
import 'tooltip_theme.dart';
import 'tooltip_visibility.dart';

/// Signature for when a tooltip is triggered.
typedef TooltipTriggeredCallback = void Function();

/// Contextual information for positioning a tooltip.
///
/// This immutable data class contains all the necessary information for computing
/// the position of a tooltip relative to its target widget.
///
/// See also:
///
///  * [TooltipPositionDelegate], which uses this context to compute tooltip positions.
@immutable
class TooltipPositionContext {
  /// Creates a tooltip position context.
  const TooltipPositionContext({
    required this.target,
    required this.targetSize,
    required this.tooltipSize,
    required this.verticalOffset,
    required this.preferBelow,
  });

  /// The center point of the target widget in the global coordinate system.
  final Offset target;

  /// The size of the target widget that triggers the tooltip.
  final Size targetSize;

  /// The size of the tooltip itself.
  final Size tooltipSize;

  /// The configured vertical offset.
  final double verticalOffset;

  /// Whether the tooltip prefers to be positioned below the target.
  final bool preferBelow;

  @override
  bool operator ==(Object other) {