From 07fdadd1d12448f33920c4539f801cc1de9a416b Mon Sep 17 00:00:00 2001 From: Gary Qian Date: Mon, 22 Jul 2019 13:20:34 -0700 Subject: [PATCH] Add gradient text docs (#36579) --- .../flutter/lib/src/painting/text_style.dart | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index e9f6395f46..bf5b4e1653 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -166,7 +166,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// ``` /// {@end-tool} /// -/// ### Borders and stroke +/// ### Borders and stroke (Foreground) /// /// {@tool sample} /// To create bordered text, a [Paint] with [Paint.style] set to [PaintingStyle.stroke] @@ -202,6 +202,34 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// ``` /// {@end-tool} /// +/// ### Gradients (Foreground) +/// +/// {@tool sample} +/// The [foreground] property also allows effects such as gradients to be +/// applied to the text. Here we provide a [Paint] with a [ui.Gradient] +/// shader. +/// +/// ![Text gradient](https://flutter.github.io/assets-for-api-docs/assets/widgets/text_gradient.png) +/// +/// ```dart +/// Text( +/// 'Greetings, planet!', +/// style: TextStyle( +/// fontSize: 40, +/// foreground: Paint() +/// ..shader = ui.Gradient.linear( +/// const Offset(0, 20), +/// const Offset(150, 20), +/// [ +/// Colors.red, +/// Colors.yellow, +/// ], +/// ) +/// ), +/// ) +/// ``` +/// {@end-tool} +/// /// ### Custom Fonts /// /// Custom fonts can be declared in the `pubspec.yaml` file as shown below: