Pass locale along to RenderParagraph (#17879)
This commit is contained in:
parent
49bcda52a2
commit
f1e4defbbc
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as ui show Gradient, Shader, TextBox;
|
||||
import 'dart:ui' as ui show Gradient, Shader, TextBox, Locale;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
@ -44,6 +44,7 @@ class RenderParagraph extends RenderBox {
|
||||
TextOverflow overflow: TextOverflow.clip,
|
||||
double textScaleFactor: 1.0,
|
||||
int maxLines,
|
||||
ui.Locale locale,
|
||||
}) : assert(text != null),
|
||||
assert(text.debugAssertIsValid()),
|
||||
assert(textAlign != null),
|
||||
@ -61,6 +62,7 @@ class RenderParagraph extends RenderBox {
|
||||
textScaleFactor: textScaleFactor,
|
||||
maxLines: maxLines,
|
||||
ellipsis: overflow == TextOverflow.ellipsis ? _kEllipsis : null,
|
||||
locale: locale,
|
||||
);
|
||||
|
||||
final TextPainter _textPainter;
|
||||
@ -174,6 +176,15 @@ class RenderParagraph extends RenderBox {
|
||||
markNeedsLayout();
|
||||
}
|
||||
|
||||
ui.Locale get locale => _textPainter.locale;
|
||||
set locale(ui.Locale value) {
|
||||
if (_textPainter.locale == value)
|
||||
return;
|
||||
_textPainter.locale = locale;
|
||||
_overflowShader = null;
|
||||
markNeedsLayout();
|
||||
}
|
||||
|
||||
void _layoutText({ double minWidth: 0.0, double maxWidth: double.infinity }) {
|
||||
final bool widthMatters = softWrap || overflow == TextOverflow.ellipsis;
|
||||
_textPainter.layout(minWidth: minWidth, maxWidth: widthMatters ? maxWidth : double.infinity);
|
||||
|
@ -10,6 +10,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import 'debug.dart';
|
||||
import 'framework.dart';
|
||||
import 'localizations.dart';
|
||||
|
||||
export 'package:flutter/animation.dart';
|
||||
export 'package:flutter/foundation.dart' show
|
||||
@ -4341,6 +4342,7 @@ class RichText extends LeafRenderObjectWidget {
|
||||
overflow: overflow,
|
||||
textScaleFactor: textScaleFactor,
|
||||
maxLines: maxLines,
|
||||
locale: Localizations.localeOf(context, nullOk: true),
|
||||
);
|
||||
}
|
||||
|
||||
@ -4354,7 +4356,8 @@ class RichText extends LeafRenderObjectWidget {
|
||||
..softWrap = softWrap
|
||||
..overflow = overflow
|
||||
..textScaleFactor = textScaleFactor
|
||||
..maxLines = maxLines;
|
||||
..maxLines = maxLines
|
||||
..locale = Localizations.localeOf(context, nullOk: true);
|
||||
}
|
||||
|
||||
@override
|
||||
|
Loading…
x
Reference in New Issue
Block a user