Document difference between softWrap and maxLine (#139363)
This PR fixes #13631 through documentation as suggested in https://github.com/flutter/flutter/issues/13631#issuecomment-354902727. Since the documentation additions rely on new screenshots this PR will be accompanied by a PR in the assets repository.
This commit is contained in:
committed by
GitHub
parent
008ecd8c9e
commit
b893884f50
@@ -338,20 +338,52 @@ class DefaultTextHeightBehavior extends InheritedTheme {
|
||||
/// This example shows how to display text using the [Text] widget with the
|
||||
/// [overflow] set to [TextOverflow.ellipsis].
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Text(
|
||||
/// 'Hello, $_name! How are you?',
|
||||
/// textAlign: TextAlign.center,
|
||||
/// overflow: TextOverflow.ellipsis,
|
||||
/// style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
/// )
|
||||
/// Container(
|
||||
/// width: 100,
|
||||
/// decoration: BoxDecoration(border: Border.all()),
|
||||
/// child: Text(overflow: TextOverflow.ellipsis, 'Hello $_name, how are you?'))
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
///
|
||||
/// {@tool snippet}
|
||||
///
|
||||
/// Setting [maxLines] to `1` is not equivalent to disabling soft wrapping with
|
||||
/// [softWrap]. This is apparent when using [TextOverflow.fade] as the following
|
||||
/// examples show.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Text(
|
||||
/// overflow: TextOverflow.fade,
|
||||
/// maxLines: 1,
|
||||
/// 'Hello $_name, how are you?')
|
||||
/// ```
|
||||
///
|
||||
/// Here soft wrapping is enabled and the [Text] widget tries to wrap the words
|
||||
/// "how are you?" to a second line. This is prevented by the [maxLines] value
|
||||
/// of `1`. The result is that a second line overflows and the fade appears in a
|
||||
/// horizontal direction at the bottom.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Text(
|
||||
/// overflow: TextOverflow.fade,
|
||||
/// softWrap: false,
|
||||
/// 'Hello $_name, how are you?')
|
||||
/// ```
|
||||
///
|
||||
/// Here soft wrapping is disabled with `softWrap: false` and the [Text] widget
|
||||
/// attempts to display its text in a single unbroken line. The result is that
|
||||
/// the single line overflows and the fade appears in a vertical direction at
|
||||
/// the right.
|
||||
///
|
||||
/// {@end-tool}
|
||||
///
|
||||
/// Using the [Text.rich] constructor, the [Text] widget can
|
||||
/// display a paragraph with differently styled [TextSpan]s. The sample
|
||||
/// that follows displays "Hello beautiful world" with different styles
|
||||
|
||||
Reference in New Issue
Block a user