Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
04e0fcb0
Unverified
Commit
04e0fcb0
authored
Jun 05, 2018
by
Hans Muller
Committed by
GitHub
Jun 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a typo in the render paragraph locale setter (#18189)
parent
e8bceabb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
8 deletions
+42
-8
paragraph.dart
packages/flutter/lib/src/rendering/paragraph.dart
+14
-5
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+13
-3
paragraph_test.dart
packages/flutter/test/rendering/paragraph_test.dart
+15
-0
No files found.
packages/flutter/lib/src/rendering/paragraph.dart
View file @
04e0fcb0
...
...
@@ -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
,
Locale
;
import
'dart:ui'
as
ui
show
Gradient
,
Shader
,
TextBox
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
...
...
@@ -44,7 +44,7 @@ class RenderParagraph extends RenderBox {
TextOverflow
overflow
=
TextOverflow
.
clip
,
double
textScaleFactor
=
1.0
,
int
maxLines
,
ui
.
Locale
locale
,
Locale
locale
,
})
:
assert
(
text
!=
null
),
assert
(
text
.
debugAssertIsValid
()),
assert
(
textAlign
!=
null
),
...
...
@@ -176,11 +176,19 @@ class RenderParagraph extends RenderBox {
markNeedsLayout
();
}
ui
.
Locale
get
locale
=>
_textPainter
.
locale
;
set
locale
(
ui
.
Locale
value
)
{
/// Used by this paragraph's internal [TextPainter] to select a locale-specific
/// font.
///
/// In some cases the same Unicode character may be rendered differently depending
/// on the locale. For example the '骨' character is rendered differently in
/// the Chinese and Japanese locales. In these cases the [locale] may be used
/// to select a locale-specific font.
Locale
get
locale
=>
_textPainter
.
locale
;
/// The value may be null.
set
locale
(
Locale
value
)
{
if
(
_textPainter
.
locale
==
value
)
return
;
_textPainter
.
locale
=
local
e
;
_textPainter
.
locale
=
valu
e
;
_overflowShader
=
null
;
markNeedsLayout
();
}
...
...
@@ -286,6 +294,7 @@ class RenderParagraph extends RenderBox {
text:
new
TextSpan
(
style:
_textPainter
.
text
.
style
,
text:
'
\
u2026'
),
textDirection:
textDirection
,
textScaleFactor:
textScaleFactor
,
locale:
locale
,
)..
layout
();
if
(
didOverflowWidth
)
{
double
fadeEnd
,
fadeStart
;
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
04e0fcb0
...
...
@@ -235,7 +235,7 @@ class ShaderMask extends SingleChildRenderObjectWidget {
/// it can customize the shader to the size and location of the child.
///
/// Typically this will use a [LinearGradient], [RadialGradient], or
/// [SweepGradient] to create the [dart:ui.Shader], though the
/// [SweepGradient] to create the [dart:ui.Shader], though the
/// [dart:ui.ImageShader] class could also be used.
final
ShaderCallback
shaderCallback
;
...
...
@@ -4289,6 +4289,7 @@ class RichText extends LeafRenderObjectWidget {
this
.
overflow
=
TextOverflow
.
clip
,
this
.
textScaleFactor
=
1.0
,
this
.
maxLines
,
this
.
locale
,
})
:
assert
(
text
!=
null
),
assert
(
textAlign
!=
null
),
assert
(
softWrap
!=
null
),
...
...
@@ -4341,6 +4342,15 @@ class RichText extends LeafRenderObjectWidget {
/// edge of the box.
final
int
maxLines
;
/// Used to select a font when the same Unicode character can
/// be rendered differently, depending on the locale.
///
/// It's rarely necessary to set this property. By default its value
/// is inherited from the enclosing app with `Localizations.localeOf(context)`.
///
/// See [RenderParagraph.locale] for more information.
final
Locale
locale
;
@override
RenderParagraph
createRenderObject
(
BuildContext
context
)
{
assert
(
textDirection
!=
null
||
debugCheckHasDirectionality
(
context
));
...
...
@@ -4351,7 +4361,7 @@ class RichText extends LeafRenderObjectWidget {
overflow:
overflow
,
textScaleFactor:
textScaleFactor
,
maxLines:
maxLines
,
locale:
Localizations
.
localeOf
(
context
,
nullOk:
true
),
locale:
locale
??
Localizations
.
localeOf
(
context
,
nullOk:
true
),
);
}
...
...
@@ -4366,7 +4376,7 @@ class RichText extends LeafRenderObjectWidget {
..
overflow
=
overflow
..
textScaleFactor
=
textScaleFactor
..
maxLines
=
maxLines
..
locale
=
Localizations
.
localeOf
(
context
,
nullOk:
true
);
..
locale
=
locale
??
Localizations
.
localeOf
(
context
,
nullOk:
true
);
}
@override
...
...
packages/flutter/test/rendering/paragraph_test.dart
View file @
04e0fcb0
...
...
@@ -310,4 +310,19 @@ void main() {
),
);
});
test
(
'locale setter'
,
()
{
// Regression test for https://github.com/flutter/flutter/issues/18175
final
RenderParagraph
paragraph
=
new
RenderParagraph
(
const
TextSpan
(
text:
_kText
),
locale:
const
Locale
(
'zh'
,
'HK'
),
textDirection:
TextDirection
.
ltr
,
);
expect
(
paragraph
.
locale
,
const
Locale
(
'zh'
,
'HK'
));
paragraph
.
locale
=
const
Locale
(
'ja'
,
'JP'
);
expect
(
paragraph
.
locale
,
const
Locale
(
'ja'
,
'JP'
));
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment