-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#39693Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/found in release: 3.7Found to occur in 3.7Found to occur in 3.7found in release: 3.8Found to occur in 3.8Found to occur in 3.8frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Info
When tests are run on the web TextPainter.getLineBoundary includes the line terminator when the documentation states it does not. When tests are run on the native platform TextPainter.getLineBoundary return value does not include the line terminator.
In a non-test environment, when a flutter app is running on the native platform TextPainter.getLineBoundary return value does not include the line terminator.
Steps to Reproduce
The following test variation from #83392 passes with flutter test test/widgets/text_test.dart but fails with flutter test test/widgets/text_test.dart --platform chrome
test('getLineBoundary does not include newline characters', () {
const text = 'aaa\nbbb';
final paragraphStyle = ui.ParagraphStyle(
textDirection: ui.TextDirection.ltr,
);
final paragraphBuilder = ui.ParagraphBuilder(paragraphStyle)
..addText(text);
final constraints = ui.ParagraphConstraints(width: 1000);
final paragraph = paragraphBuilder.build();
paragraph.layout(constraints);
var range = paragraph.getLineBoundary(const TextPosition(offset: 0));
expect(
range.textInside(text),
equals('aaa'),
);
expect(range.start, 0);
expect(range.end, 3);
range = paragraph.getLineBoundary(const TextPosition(offset: 5));
expect(
range.textInside(text),
equals('bbb'),
);
expect(range.start, 4);
expect(range.end, 7);
});There is also conflicting documentation in text_painter.dart and text.dart
text_painter (last updated #83626):
/// Returns the text range of the line at the given offset.
///
/// The newline (if any) is not returned as part of the range.
text:
/// Returns the [TextRange] of the line at the given [TextPosition].
///
/// The newline (if any) is returned as part of the range.
///
/// Not valid until after layout.
///
/// This can potentially be expensive, since it needs to compute the line
/// metrics, so use it sparingly.
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/found in release: 3.7Found to occur in 3.7Found to occur in 3.7found in release: 3.8Found to occur in 3.8Found to occur in 3.8frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version