Skip to content

Commit

Permalink
## 6.0.5
Browse files Browse the repository at this point in the history
* Remove unnecessary assert (assert(textPainter.width >= lastChild!.size.width))
* Initialize _offset with Offset.zero.
  • Loading branch information
zmtzawqlp committed May 4, 2021
1 parent 0ba7076 commit 766bd35
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 6.0.5

* Remove unnecessary assert (assert(textPainter.width >= lastChild!.size.width))
* Initialize _offset with Offset.zero.

## 6.0.4

* Fix find no overflow endless loop. #105
Expand Down
33 changes: 15 additions & 18 deletions example/lib/pages/text_selection_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:ff_annotation_route_library/ff_annotation_route_library.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart' hide CircularProgressIndicator;
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter/foundation.dart';

@FFRoute(
name: 'fluttercandies://TextSelectionDemo',
Expand Down Expand Up @@ -59,23 +58,21 @@ class _TextSelectionDemoState extends State<TextSelectionDemo> {
//overflow: ExtendedTextOverflow.ellipsis,
style: const TextStyle(fontSize: 14, color: Colors.grey),
maxLines: 4,
overflowWidget: kIsWeb
? null
: TextOverflowWidget(
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('\u2026 '),
InkWell(
child: const Text('more'),
onTap: () {
launch(
'https://github.com/fluttercandies/extended_text');
},
)
],
),
),
overflowWidget: TextOverflowWidget(
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('\u2026 '),
InkWell(
child: const Text('more'),
onTap: () {
launch(
'https://github.com/fluttercandies/extended_text');
},
)
],
),
),
selectionEnabled: true,
selectionControls: _myTextSelectionControls,
),
Expand Down
10 changes: 5 additions & 5 deletions lib/src/extended_render_paragraph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class ExtendedRenderParagraph extends ExtendedTextSelectionRenderObject
size = constraints.constrain(textSize);
}

late Offset _offset;
Offset _offset = Offset.zero;
@override
void paint(PaintingContext context, Offset offset) {
_offset = offset;
Expand Down Expand Up @@ -453,7 +453,7 @@ class ExtendedRenderParagraph extends ExtendedTextSelectionRenderObject
_paintTextOverflow(context, offset);
//clip rect of over flow
if (_overflowRect != null) {
context.canvas.saveLayer(_offset & size, Paint());
context.canvas.saveLayer(offset & size, Paint());
}
_paintSelection(context, offset);
_paintSpecialText(context, offset);
Expand All @@ -464,16 +464,16 @@ class ExtendedRenderParagraph extends ExtendedTextSelectionRenderObject
if (_overflowRects != null && _overflowRects!.isNotEmpty) {
for (final Rect rect in _overflowRects!) {
context.canvas.drawRect(
rect.shift(_offset), Paint()..blendMode = BlendMode.clear);
rect.shift(offset), Paint()..blendMode = BlendMode.clear);
}
}
context.canvas.drawRect(
_overflowRect!.shift(_offset), Paint()..blendMode = BlendMode.clear);
_overflowRect!.shift(offset), Paint()..blendMode = BlendMode.clear);

if (kDebugMode &&
overflowWidget != null &&
overflowWidget!.debugOverflowRectColor != null) {
context.canvas.drawRect(_overflowRect!.shift(_offset),
context.canvas.drawRect(_overflowRect!.shift(offset),
Paint()..color = overflowWidget!.debugOverflowRectColor!);
}

Expand Down
5 changes: 3 additions & 2 deletions lib/src/text_overflow_render_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mixin TextOverflowMixin on ExtendedTextSelectionRenderObject {
if (!_hasVisualOverflow) {
return;
}
assert(textPainter.width >= lastChild!.size.width);
//assert(textPainter.width >= lastChild!.size.width);

final TextParentData textParentData =
lastChild!.parentData as TextParentData;
Expand Down Expand Up @@ -144,6 +144,7 @@ mixin TextOverflowMixin on ExtendedTextSelectionRenderObject {
overflowWidgetSize.width, textPainter.preferredLineHeight / 2));
position =
convertTextPainterPostionToTextInputPostion(text!, position)!;

end = position.offset;
}

Expand Down Expand Up @@ -436,7 +437,7 @@ mixin TextOverflowMixin on ExtendedTextSelectionRenderObject {

void _paintTextOverflow(PaintingContext context, Offset offset) {
if (overflowWidget != null && _overflowRect != null) {
assert(textPainter.width >= lastChild!.size.width);
//assert(textPainter.width >= lastChild!.size.width);

final TextParentData textParentData =
lastChild!.parentData as TextParentData;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: extended_text
description: Extended official text to build special text like inline image or @somebody quickly,it also support custom background,custom over flow and custom selection toolbar and handles.
version: 6.0.4
version: 6.0.5
homepage: https://github.com/fluttercandies/extended_text

environment:
Expand Down

0 comments on commit 766bd35

Please sign in to comment.