Unverified Commit f1e4defb authored by Hans Muller's avatar Hans Muller Committed by GitHub

Pass locale along to RenderParagraph (#17879)

parent 49bcda52
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment