Add SemanticService.tooltip method for Android tooltips (#16978)
This commit is contained in:
parent
6334da0109
commit
f0c4bc30c6
@ -147,6 +147,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
|
||||
_entry = new OverlayEntry(builder: (BuildContext context) => overlay);
|
||||
Overlay.of(context, debugRequiredFor: widget).insert(_entry);
|
||||
GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent);
|
||||
SemanticsService.tooltip(widget.message);
|
||||
_controller.forward();
|
||||
return true;
|
||||
}
|
||||
|
@ -88,3 +88,22 @@ class AnnounceSemanticsEvent extends SemanticsEvent {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// An event for a semantic announcement of a tooltip.
|
||||
///
|
||||
/// This is only used by Android to announce tooltip values.
|
||||
class TooltipSemanticsEvent extends SemanticsEvent {
|
||||
|
||||
/// Constructs an event that triggers a tooltip announcement by the platform.
|
||||
const TooltipSemanticsEvent(this.message) : super('tooltip');
|
||||
|
||||
/// The text content of the tooltip.
|
||||
final String message;
|
||||
|
||||
@override
|
||||
Map<String, dynamic> getDataMap() {
|
||||
return <String, dynamic>{
|
||||
'message': message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import 'dart:ui' show TextDirection;
|
||||
|
||||
import 'package:flutter/services.dart' show SystemChannels;
|
||||
|
||||
import 'semantics_event.dart' show AnnounceSemanticsEvent;
|
||||
import 'semantics_event.dart' show AnnounceSemanticsEvent, TooltipSemanticsEvent;
|
||||
|
||||
|
||||
/// Allows access to the platform's accessibility services.
|
||||
@ -31,4 +31,12 @@ class SemanticsService {
|
||||
final AnnounceSemanticsEvent event = new AnnounceSemanticsEvent(message, textDirection);
|
||||
await SystemChannels.accessibility.send(event.toMap());
|
||||
}
|
||||
|
||||
/// Sends a semantic announcement of a tooltip.
|
||||
///
|
||||
/// This is only used by Android.
|
||||
static Future<Null> tooltip(String message) async {
|
||||
final TooltipSemanticsEvent event = new TooltipSemanticsEvent(message);
|
||||
await SystemChannels.accessibility.send(event.toMap());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user