From 5511abd90fd2f0e1f833b357d83e92b1d9199bdd Mon Sep 17 00:00:00 2001 From: Tekeshwar Singh Date: Sun, 1 Nov 2020 16:13:03 +0530 Subject: [PATCH] AdoptAWidget: Tooltip (#69518) --- .../flutter/lib/src/material/tooltip.dart | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index 955c2e997d..0a3ad3d4c7 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -30,6 +30,61 @@ import 'tooltip_theme.dart'; /// /// {@youtube 560 315 https://www.youtube.com/watch?v=EeEfD5fI-5Q} /// +/// {@tool dartpad --template=stateless_widget_material} +/// +/// This example show a basic [Tooltip] which has a [Text] as child. +/// [message] contains your label to be shown by the tooltip when +/// the child that Tooltip wraps is long pressed. +/// +/// ```dart +/// Widget build(BuildContext context) { +/// return Center( +/// child: Tooltip( +/// message: "I am a Tooltip", +/// child: Text("Tap this text and hold down to show a tooltip."), +/// ), +/// ); +/// } +/// ``` +/// {@end-tool} +/// +/// {@tool dartpad --template=stateless_widget_material} +/// +/// This example covers most of the attributes available in Tooltip. +/// `decoration` has been used to give a gradient and borderRadius to Tooltip. +/// `height` has been used to set a specific height of the Tooltip. +/// `preferBelow` is false, the tooltip will prefer showing above [Tooltip]'s child widget. +/// However, it may show the tooltip below if there's not enough space +/// above the widget. +/// `textStyle` has been used to set the font size of the 'message'. +/// `showDuration` accepts a Duration to continue showing the message after the long +/// press has been released. +/// `waitDuration` accepts a Duration for which a mouse pointer has to hover over the child +/// widget before the tooltip is shown. +/// +/// ```dart +/// Widget build(BuildContext context) { +/// return Center( +/// child: Tooltip( +/// message: "I am a Tooltip", +/// child: Text("Tap this text and hold down to show a tooltip."), +/// decoration: BoxDecoration( +/// borderRadius: BorderRadius.circular(25), +/// gradient: LinearGradient(colors: [Colors.amber, Colors.red]), +/// ), +/// height: 50, +/// padding: EdgeInsets.all(8.0), +/// preferBelow: false, +/// textStyle: TextStyle( +/// fontSize: 24, +/// ), +/// showDuration: Duration(seconds: 2), +/// waitDuration: Duration(seconds: 1), +/// ), +/// ); +/// } +/// ``` +/// {@end-tool} /// /// See also: ///