23 lines
775 B
Dart
23 lines
775 B
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
/// Carries render-time collaborators (the link-tap hook) down the node tree so
|
|
/// individual node widgets stay pure `(node) => Widget` builders.
|
|
class PmRenderScope extends InheritedWidget {
|
|
/// Invoked when a link mark or an image `href` is tapped. The navigation /
|
|
/// URL policy is injected from outside — the renderer only exposes the hook.
|
|
final void Function(String href)? onLinkTap;
|
|
|
|
const PmRenderScope({
|
|
required this.onLinkTap,
|
|
required super.child,
|
|
super.key,
|
|
});
|
|
|
|
static PmRenderScope? maybeOf(BuildContext context) =>
|
|
context.dependOnInheritedWidgetOfExactType<PmRenderScope>();
|
|
|
|
@override
|
|
bool updateShouldNotify(PmRenderScope oldWidget) =>
|
|
oldWidget.onLinkTap != onLinkTap;
|
|
}
|