@ -16,13 +16,13 @@ import 'package:flutter_quill/models/documents/nodes/embed.dart';
import ' package:flutter_quill/models/documents/nodes/leaf.dart ' as leaf ;
import ' package:flutter_quill/models/documents/nodes/line.dart ' ;
import ' package:flutter_quill/models/documents/nodes/node.dart ' ;
import ' package:flutter_quill/utils/universal_ui/universal_ui.dart ' ;
import ' package:flutter_quill/widgets/image.dart ' ;
import ' package:flutter_quill/widgets/raw_editor.dart ' ;
import ' package:flutter_quill/widgets/responsive_widget.dart ' ;
import ' package:flutter_quill/widgets/text_selection.dart ' ;
import ' package:string_validator/string_validator.dart ' ;
import ' package:universal_html/prefer_universal/html.dart ' as html ;
import ' package:universal_ui/universal_ui.dart ' ;
import ' package:universal_html/html.dart ' as html ;
import ' package:url_launcher/url_launcher.dart ' ;
import ' box.dart ' ;
@ -53,9 +53,9 @@ abstract class EditorState extends State<RawEditor> {
void setTextEditingValue ( TextEditingValue value ) ;
RenderEditor getRenderEditor ( ) ;
RenderEditor ? getRenderEditor ( ) ;
EditorTextSelectionOverlay getSelectionOverlay ( ) ;
EditorTextSelectionOverlay ? getSelectionOverlay ( ) ;
bool showToolbar ( ) ;
@ -146,51 +146,45 @@ class QuillEditor extends StatefulWidget {
final bool scrollable ;
final EdgeInsetsGeometry padding ;
final bool autoFocus ;
final bool showCursor ;
final bool ? showCursor ;
final bool readOnly ;
final String placeholder ;
final bool enableInteractiveSelection ;
final double minHeight ;
final double maxHeight ;
final DefaultStyles customStyles ;
final String ? placeholder ;
final bool ? enableInteractiveSelection ;
final double ? minHeight ;
final double ? maxHeight ;
final DefaultStyles ? customStyles ;
final bool expands ;
final TextCapitalization textCapitalization ;
final Brightness keyboardAppearance ;
final ScrollPhysics scrollPhysics ;
final ValueChanged < String > onLaunchUrl ;
final ScrollPhysics ? scrollPhysics ;
final ValueChanged < String > ? onLaunchUrl ;
final EmbedBuilder embedBuilder ;
QuillEditor (
{ @ required this . controller ,
@ required this . focusNode ,
@ required this . scrollController ,
@ required this . scrollable ,
@ required this . padding ,
@ required this . autoFocus ,
{ Key ? key ,
required this . controller ,
required this . focusNode ,
required this . scrollController ,
required this . scrollable ,
required this . padding ,
required this . autoFocus ,
this . showCursor ,
@ required this . readOnly ,
required this . readOnly ,
this . placeholder ,
this . enableInteractiveSelection ,
this . minHeight ,
this . maxHeight ,
this . customStyles ,
@ required this . expands ,
required this . expands ,
this . textCapitalization = TextCapitalization . sentences ,
this . keyboardAppearance = Brightness . light ,
this . scrollPhysics ,
this . onLaunchUrl ,
this . embedBuilder =
kIsWeb ? _defaultEmbedBuilderWeb : _defaultEmbedBuilder } )
: assert ( controller ! = null ) ,
assert ( scrollController ! = null ) ,
assert ( scrollable ! = null ) ,
assert ( focusNode ! = null ) ,
assert ( autoFocus ! = null ) ,
assert ( readOnly ! = null ) ,
assert ( embedBuilder ! = null ) ;
kIsWeb ? _defaultEmbedBuilderWeb : _defaultEmbedBuilder } ) ;
factory QuillEditor . basic (
{ @ required QuillController controller , bool readOnly } ) {
{ Key ? key , required QuillController controller , required bool readOnly } ) {
return QuillEditor (
controller: controller ,
scrollController: ScrollController ( ) ,
@ -209,8 +203,9 @@ class QuillEditor extends StatefulWidget {
class _QuillEditorState extends State < QuillEditor >
implements EditorTextSelectionGestureDetectorBuilderDelegate {
final GlobalKey < EditorState > _editorKey = GlobalKey < EditorState > ( ) ;
EditorTextSelectionGestureDetectorBuilder _selectionGestureDetectorBuilder ;
GlobalKey < EditorState > _editorKey = GlobalKey < EditorState > ( ) ;
late EditorTextSelectionGestureDetectorBuilder
_selectionGestureDetectorBuilder ;
@ override
void initState ( ) {
@ -227,10 +222,10 @@ class _QuillEditorState extends State<QuillEditor>
TextSelectionControls textSelectionControls ;
bool paintCursorAboveText ;
bool cursorOpacityAnimates ;
Offset cursorOffset ;
Color cursorColor ;
Offset ? cursorOffset ;
Color ? cursorColor ;
Color selectionColor ;
Radius cursorRadius ;
Radius ? cursorRadius ;
switch ( theme . platform ) {
case TargetPlatform . android:
@ -301,7 +296,7 @@ class _QuillEditorState extends State<QuillEditor>
selectionColor ,
textSelectionControls ,
widget . keyboardAppearance ,
widget . enableInteractiveSelection ,
widget . enableInteractiveSelection ! ,
widget . scrollPhysics ,
widget . embedBuilder ) ,
) ;
@ -318,12 +313,12 @@ class _QuillEditorState extends State<QuillEditor>
}
@ override
bool getSelectionEnabled ( ) {
bool ? getSelectionEnabled ( ) {
return widget . enableInteractiveSelection ;
}
_requestKeyboard ( ) {
_editorKey . currentState . requestKeyboard ( ) ;
_editorKey . currentState ! . requestKeyboard ( ) ;
}
}
@ -336,8 +331,8 @@ class _QuillEditorSelectionGestureDetectorBuilder
@ override
onForcePressStart ( ForcePressDetails details ) {
super . onForcePressStart ( details ) ;
if ( delegate . getSelectionEnabled ( ) & & shouldShowSelectionToolbar ) {
getEditor ( ) . showToolbar ( ) ;
if ( delegate . getSelectionEnabled ( ) ! & & shouldShowSelectionToolbar ) {
getEditor ( ) ! . showToolbar ( ) ;
}
}
@ -346,13 +341,13 @@ class _QuillEditorSelectionGestureDetectorBuilder
@ override
void onSingleLongTapMoveUpdate ( LongPressMoveUpdateDetails details ) {
if ( ! delegate . getSelectionEnabled ( ) ) {
if ( ! delegate . getSelectionEnabled ( ) ! ) {
return ;
}
switch ( Theme . of ( _state . context ) . platform ) {
case TargetPlatform . iOS:
case TargetPlatform . macOS:
getRenderEditor ( ) . selectPositionAt (
getRenderEditor ( ) ! . selectPositionAt (
details . globalPosition ,
null ,
SelectionChangedCause . longPress ,
@ -362,7 +357,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
case TargetPlatform . fuchsia:
case TargetPlatform . linux:
case TargetPlatform . windows:
getRenderEditor ( ) . selectWordsInRange (
getRenderEditor ( ) ! . selectWordsInRange (
details . globalPosition - details . offsetFromOrigin ,
details . globalPosition ,
SelectionChangedCause . longPress ,
@ -378,9 +373,9 @@ class _QuillEditorSelectionGestureDetectorBuilder
return false ;
}
TextPosition pos =
getRenderEditor ( ) . getPositionForOffset ( details . globalPosition ) ;
getRenderEditor ( ) ! . getPositionForOffset ( details . globalPosition ) ;
containerNode . ChildQuery result =
getEditor ( ) . widget . controller . document . queryChild ( pos . offset ) ;
getEditor ( ) ! . widget . controller . document . queryChild ( pos . offset ) ;
if ( result . node = = null ) {
return false ;
}
@ -391,7 +386,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
if ( line . length = = 1 ) {
/ / tapping when no text yet on this line
_flipListCheckbox ( pos , line , segmentResult ) ;
getEditor ( ) . widget . controller . updateSelection (
getEditor ( ) ! . widget . controller . updateSelection (
TextSelection . collapsed ( offset: pos . offset ) , ChangeSource . LOCAL ) ;
return true ;
}
@ -399,33 +394,34 @@ class _QuillEditorSelectionGestureDetectorBuilder
}
leaf . Leaf segment = segmentResult . node as leaf . Leaf ;
if ( segment . style . containsKey ( Attribute . link . key ) ) {
var launchUrl = getEditor ( ) . widget . onLaunchUrl ;
var launchUrl = getEditor ( ) ! . widget . onLaunchUrl ;
if ( launchUrl = = null ) {
launchUrl = _launchUrl ;
}
String link = segment . style . attributes [ Attribute . link . key ] . value ;
if ( getEditor ( ) . widget . readOnly & & link ! = null ) {
String ? link = segment . style . attributes [ Attribute . link . key ] ! . value ;
if ( getEditor ( ) ! . widget . readOnly & & link ! = null ) {
link = link . trim ( ) ;
if ( ! linkPrefixes
. any ( ( linkPrefix ) = > link . toLowerCase ( ) . startsWith ( linkPrefix ) ) ) {
. any ( ( linkPrefix ) = > link ! . toLowerCase ( ) . startsWith ( linkPrefix ) ) ) {
link = ' https:// $ link ' ;
}
launchUrl ( link ) ;
}
return false ;
}
if ( getEditor ( ) . widget . readOnly & & segment . value is BlockEmbed ) {
if ( getEditor ( ) ! . widget . readOnly & & segment . value is BlockEmbed ) {
BlockEmbed blockEmbed = segment . value as BlockEmbed ;
if ( blockEmbed . type = = ' image ' ) {
final String imageUrl = blockEmbed . data ;
Navigator . push (
getEditor ( ) . context ,
getEditor ( ) ! . context ,
MaterialPageRoute (
builder: ( context ) = > ImageTapWrapper (
imageProvider: imageUrl . startsWith ( ' http ' )
? NetworkImage ( imageUrl )
: isBase64 ( imageUrl )
? Image . memory ( base64 . decode ( imageUrl ) )
as ImageProvider < Object > ?
: FileImage ( io . File ( imageUrl ) ) ,
) ,
) ,
@ -441,25 +437,25 @@ class _QuillEditorSelectionGestureDetectorBuilder
bool _flipListCheckbox (
TextPosition pos , Line line , containerNode . ChildQuery segmentResult ) {
if ( getEditor ( ) . widget . readOnly | |
if ( getEditor ( ) ! . widget . readOnly | |
! line . style . containsKey ( Attribute . list . key ) | |
segmentResult . offset ! = 0 ) {
return false ;
}
/ / segmentResult . offset = = 0 means tap at the beginning of the TextLine
String listVal = line . style . attributes [ Attribute . list . key ] . value ;
String ? listVal = line . style . attributes [ Attribute . list . key ] ! . value ;
if ( listVal = = Attribute . unchecked . value ) {
getEditor ( )
getEditor ( ) !
. widget
. controller
. formatText ( pos . offset , 0 , Attribute . checked ) ;
} else if ( listVal = = Attribute . checked . value ) {
getEditor ( )
getEditor ( ) !
. widget
. controller
. formatText ( pos . offset , 0 , Attribute . unchecked ) ;
}
getEditor ( ) . widget . controller . updateSelection (
getEditor ( ) ! . widget . controller . updateSelection (
TextSelection . collapsed ( offset: pos . offset ) , ChangeSource . LOCAL ) ;
return true ;
}
@ -470,11 +466,11 @@ class _QuillEditorSelectionGestureDetectorBuilder
@ override
onSingleTapUp ( TapUpDetails details ) {
getEditor ( ) . hideToolbar ( ) ;
getEditor ( ) ! . hideToolbar ( ) ;
bool positionSelected = _onTapping ( details ) ;
if ( delegate . getSelectionEnabled ( ) & & ! positionSelected ) {
if ( delegate . getSelectionEnabled ( ) ! & & ! positionSelected ) {
switch ( Theme . of ( _state . context ) . platform ) {
case TargetPlatform . iOS:
case TargetPlatform . macOS:
@ -482,11 +478,11 @@ class _QuillEditorSelectionGestureDetectorBuilder
case PointerDeviceKind . mouse:
case PointerDeviceKind . stylus:
case PointerDeviceKind . invertedStylus:
getRenderEditor ( ) . selectPosition ( SelectionChangedCause . tap ) ;
getRenderEditor ( ) ! . selectPosition ( SelectionChangedCause . tap ) ;
break ;
case PointerDeviceKind . touch:
case PointerDeviceKind . unknown:
getRenderEditor ( ) . selectWordEdge ( SelectionChangedCause . tap ) ;
getRenderEditor ( ) ! . selectWordEdge ( SelectionChangedCause . tap ) ;
break ;
}
break ;
@ -494,7 +490,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
case TargetPlatform . fuchsia:
case TargetPlatform . linux:
case TargetPlatform . windows:
getRenderEditor ( ) . selectPosition ( SelectionChangedCause . tap ) ;
getRenderEditor ( ) ! . selectPosition ( SelectionChangedCause . tap ) ;
break ;
}
}
@ -503,11 +499,11 @@ class _QuillEditorSelectionGestureDetectorBuilder
@ override
void onSingleLongTapStart ( LongPressStartDetails details ) {
if ( delegate . getSelectionEnabled ( ) ) {
if ( delegate . getSelectionEnabled ( ) ! ) {
switch ( Theme . of ( _state . context ) . platform ) {
case TargetPlatform . iOS:
case TargetPlatform . macOS:
getRenderEditor ( ) . selectPositionAt (
getRenderEditor ( ) ! . selectPositionAt (
details . globalPosition ,
null ,
SelectionChangedCause . longPress ,
@ -517,7 +513,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
case TargetPlatform . fuchsia:
case TargetPlatform . linux:
case TargetPlatform . windows:
getRenderEditor ( ) . selectWord ( SelectionChangedCause . longPress ) ;
getRenderEditor ( ) ! . selectWord ( SelectionChangedCause . longPress ) ;
Feedback . forLongPress ( _state . context ) ;
break ;
default :
@ -548,7 +544,7 @@ class RenderEditor extends RenderEditableContainerBox
final ValueNotifier < bool > _selectionEndInViewport = ValueNotifier < bool > ( true ) ;
RenderEditor (
List < RenderEditableBox > children ,
List < RenderEditableBox > ? children ,
TextDirection textDirection ,
EdgeInsetsGeometry padding ,
this . document ,
@ -558,11 +554,7 @@ class RenderEditor extends RenderEditableContainerBox
this . _startHandleLayerLink ,
this . _endHandleLayerLink ,
EdgeInsets floatingCursorAddedMargin )
: assert ( document ! = null ) ,
assert ( textDirection ! = null ) ,
assert ( _hasFocus ! = null ) ,
assert ( floatingCursorAddedMargin ! = null ) ,
super (
: super (
children ,
document . root ,
textDirection ,
@ -570,7 +562,6 @@ class RenderEditor extends RenderEditableContainerBox
) ;
setDocument ( Document doc ) {
assert ( doc ! = null ) ;
if ( document = = doc ) {
return ;
}
@ -579,7 +570,6 @@ class RenderEditor extends RenderEditableContainerBox
}
setHasFocus ( bool h ) {
assert ( h ! = null ) ;
if ( _hasFocus = = h ) {
return ;
}
@ -614,15 +604,13 @@ class RenderEditor extends RenderEditableContainerBox
@ override
List < TextSelectionPoint > getEndpointsForSelection (
TextSelection textSelection ) {
assert ( constraints ! = null ) ;
if ( textSelection . isCollapsed ) {
RenderEditableBox child = childAtPosition ( textSelection . extent ) ;
TextPosition localPosition = TextPosition (
offset:
textSelection . extentOffset - child . getContainer ( ) . getOffset ( ) ) ;
Offset localOffset = child . getOffsetForCaret ( localPosition ) ;
BoxParentData parentData = child . parentData ;
BoxParentData parentData = child . parentData as BoxParentData ;
return < TextSelectionPoint > [
TextSelectionPoint (
Offset ( 0.0 , child . preferredLineHeight ( localPosition ) ) +
@ -632,7 +620,7 @@ class RenderEditor extends RenderEditableContainerBox
] ;
}
Node baseNode = _container . queryChild ( textSelection . start , false ) . node ;
Node ? baseNode = _container . queryChild ( textSelection . start , false ) . node ;
var baseChild = firstChild ;
while ( baseChild ! = null ) {
@ -643,7 +631,7 @@ class RenderEditor extends RenderEditableContainerBox
}
assert ( baseChild ! = null ) ;
BoxParentData baseParentData = baseChild . parentData ;
BoxParentData baseParentData = baseChild ! . parentData as BoxP arentData ;
TextSelection baseSelection =
localSelection ( baseChild . getContainer ( ) , textSelection , true ) ;
TextSelectionPoint basePoint =
@ -651,8 +639,8 @@ class RenderEditor extends RenderEditableContainerBox
basePoint = TextSelectionPoint (
basePoint . point + baseParentData . offset , basePoint . direction ) ;
Node extentNode = _container . queryChild ( textSelection . end , false ) . node ;
var extentChild = baseChild ;
Node ? extentNode = _container . queryChild ( textSelection . end , false ) . node ;
RenderEditableBox ? extentChild = baseChild ;
while ( extentChild ! = null ) {
if ( extentChild . getContainer ( ) = = extentNode ) {
break ;
@ -661,7 +649,7 @@ class RenderEditor extends RenderEditableContainerBox
}
assert ( extentChild ! = null ) ;
BoxParentData extentParentData = extentChild . parentData ;
BoxParentData extentParentData = extentChild ! . parentData as BoxP arentData ;
TextSelection extentSelection =
localSelection ( extentChild . getContainer ( ) , textSelection , true ) ;
TextSelectionPoint extentPoint =
@ -672,7 +660,7 @@ class RenderEditor extends RenderEditableContainerBox
return < TextSelectionPoint > [ basePoint , extentPoint ] ;
}
Offset _lastTapDownPosition ;
Offset ? _lastTapDownPosition ;
@ override
handleTapDown ( TapDownDetails details ) {
@ -682,14 +670,9 @@ class RenderEditor extends RenderEditableContainerBox
@ override
selectWordsInRange (
Offset from ,
Offset to ,
Offset ? to ,
SelectionChangedCause cause ,
) {
assert ( cause ! = null ) ;
assert ( from ! = null ) ;
if ( onSelectionChanged = = null ) {
return ;
}
TextPosition firstPosition = getPositionForOffset ( from ) ;
TextSelection firstWord = selectWordAtPosition ( firstPosition ) ;
TextSelection lastWord =
@ -717,19 +700,13 @@ class RenderEditor extends RenderEditableContainerBox
! focusingEmpty ) {
return ;
}
if ( onSelectionChanged ! = null ) {
onSelectionChanged ( nextSelection , cause ) ;
}
onSelectionChanged ( nextSelection , cause ) ;
}
@ override
selectWordEdge ( SelectionChangedCause cause ) {
assert ( cause ! = null ) ;
assert ( _lastTapDownPosition ! = null ) ;
if ( onSelectionChanged = = null ) {
return ;
}
TextPosition position = getPositionForOffset ( _lastTapDownPosition ) ;
TextPosition position = getPositionForOffset ( _lastTapDownPosition ! ) ;
RenderEditableBox child = childAtPosition ( position ) ;
int nodeOffset = child . getContainer ( ) . getOffset ( ) ;
TextPosition localPosition = TextPosition (
@ -759,16 +736,11 @@ class RenderEditor extends RenderEditableContainerBox
@ override
selectPositionAt (
Offset from ,
Offset to ,
Offset ? to ,
SelectionChangedCause cause ,
) {
assert ( cause ! = null ) ;
assert ( from ! = null ) ;
if ( onSelectionChanged = = null ) {
return ;
}
TextPosition fromPosition = getPositionForOffset ( from ) ;
TextPosition toPosition = to = = null ? null : getPositionForOffset ( to ) ;
TextPosition ? toPosition = to = = null ? null : getPositionForOffset ( to ) ;
int baseOffset = fromPosition . offset ;
int extentOffset = fromPosition . offset ;
@ -787,12 +759,12 @@ class RenderEditor extends RenderEditableContainerBox
@ override
selectWord ( SelectionChangedCause cause ) {
selectWordsInRange ( _lastTapDownPosition , null , cause ) ;
selectWordsInRange ( _lastTapDownPosition ! , null , cause ) ;
}
@ override
selectPosition ( SelectionChangedCause cause ) {
selectPositionAt ( _lastTapDownPosition , null , cause ) ;
selectPositionAt ( _lastTapDownPosition ! , null , cause ) ;
}
@ override
@ -837,7 +809,7 @@ class RenderEditor extends RenderEditableContainerBox
}
@ override
bool hitTestChildren ( BoxHitTestResult result , { Offset position } ) {
bool hitTestChildren ( BoxHitTestResult result , { required Offset position } ) {
return defaultHitTestChildren ( result , position: position ) ;
}
@ -877,9 +849,9 @@ class RenderEditor extends RenderEditableContainerBox
@ override
TextPosition getPositionForOffset ( Offset offset ) {
Offset local = globalToLocal ( offset ) ;
RenderEditableBox child = childAtOffset ( local ) ;
RenderEditableBox child = childAtOffset ( local ) ! ;
BoxParentData parentData = child . parentData ;
BoxParentData parentData = child . parentData as BoxParentData ;
Offset localOffset = local - parentData . offset ;
TextPosition localPosition = child . getPositionForOffset ( localOffset ) ;
return TextPosition (
@ -888,7 +860,7 @@ class RenderEditor extends RenderEditableContainerBox
) ;
}
double getOffsetToRevealCursor (
double ? getOffsetToRevealCursor (
double viewportHeight , double scrollOffset , double offsetInViewport ) {
List < TextSelectionPoint > endpoints = getEndpointsForSelection ( selection ) ;
TextSelectionPoint endpoint = endpoints . first ;
@ -902,7 +874,7 @@ class RenderEditor extends RenderEditableContainerBox
kMargin +
offsetInViewport ;
final caretBottom = endpoint . point . dy + kMargin + offsetInViewport ;
double dy ;
double ? dy ;
if ( caretTop < scrollOffset ) {
dy = caretTop ;
} else if ( caretBottom > scrollOffset + viewportHeight ) {
@ -927,14 +899,11 @@ class RenderEditableContainerBox extends RenderBox
containerNode . Container _container ;
TextDirection textDirection ;
EdgeInsetsGeometry _padding ;
EdgeInsets _resolvedPadding ;
EdgeInsets ? _resolvedPadding ;
RenderEditableContainerBox ( List < RenderEditableBox > children , this . _container ,
RenderEditableContainerBox ( List < RenderEditableBox > ? children , this . _container ,
this . textDirection , this . _padding )
: assert ( _container ! = null ) ,
assert ( textDirection ! = null ) ,
assert ( _padding ! = null ) ,
assert ( _padding . isNonNegative ) {
: assert ( _padding . isNonNegative ) {
addAll ( children ) ;
}
@ -943,7 +912,6 @@ class RenderEditableContainerBox extends RenderBox
}
setContainer ( containerNode . Container c ) {
assert ( c ! = null ) ;
if ( _container = = c ) {
return ;
}
@ -954,7 +922,6 @@ class RenderEditableContainerBox extends RenderBox
EdgeInsetsGeometry getPadding ( ) = > _padding ;
setPadding ( EdgeInsetsGeometry value ) {
assert ( value ! = null ) ;
assert ( value . isNonNegative ) ;
if ( _padding = = value ) {
return ;
@ -963,22 +930,22 @@ class RenderEditableContainerBox extends RenderBox
_markNeedsPaddingResolution ( ) ;
}
EdgeInsets get resolvedPadding = > _resolvedPadding ;
EdgeInsets ? get resolvedPadding = > _resolvedPadding ;
_resolvePadding ( ) {
if ( _resolvedPadding ! = null ) {
return ;
}
_resolvedPadding = _padding . resolve ( textDirection ) ;
_resolvedPadding = _resolvedPadding . copyWith ( left: _resolvedPadding . left ) ;
_resolvedPadding = _resolvedPadding ! . copyWith ( left: _resolvedPadding ! . left ) ;
assert ( _resolvedPadding . isNonNegative ) ;
assert ( _resolvedPadding ! . isNonNegative ) ;
}
RenderEditableBox childAtPosition ( TextPosition position ) {
assert ( firstChild ! = null ) ;
Node targetNode = _container . queryChild ( position . offset , false ) . node ;
Node ? targetNode = _container . queryChild ( position . offset , false ) . node ;
var targetChild = firstChild ;
while ( targetChild ! = null ) {
@ -998,19 +965,19 @@ class RenderEditableContainerBox extends RenderBox
markNeedsLayout ( ) ;
}
RenderEditableBox childAtOffset ( Offset offset ) {
RenderEditableBox ? childAtOffset ( Offset offset ) {
assert ( firstChild ! = null ) ;
_resolvePadding ( ) ;
if ( offset . dy < = _resolvedPadding . top ) {
if ( offset . dy < = _resolvedPadding ! . top ) {
return firstChild ;
}
if ( offset . dy > = size . height - _resolvedPadding . bottom ) {
if ( offset . dy > = size . height - _resolvedPadding ! . bottom ) {
return lastChild ;
}
var child = firstChild ;
double dx = - offset . dx , dy = _resolvedPadding . top ;
double dx = - offset . dx , dy = _resolvedPadding ! . top ;
while ( child ! = null ) {
if ( child . size . contains ( offset . translate ( dx , - dy ) ) ) {
return child ;
@ -1037,20 +1004,21 @@ class RenderEditableContainerBox extends RenderBox
_resolvePadding ( ) ;
assert ( _resolvedPadding ! = null ) ;
double mainAxisExtent = _resolvedPadding . top ;
double mainAxisExtent = _resolvedPadding ! . top ;
var child = firstChild ;
BoxConstraints innerConstraints =
BoxConstraints . tightFor ( width: constraints . maxWidth )
. deflate ( _resolvedPadding ) ;
. deflate ( _resolvedPadding ! ) ;
while ( child ! = null ) {
child . layout ( innerConstraints , parentUsesSize: true ) ;
final EditableContainerParentData childParentData = child . parentData ;
childParentData . offset = Offset ( _resolvedPadding . left , mainAxisExtent ) ;
final EditableContainerParentData childParentData =
child . parentData as EditableContainerParentData ;
childParentData . offset = Offset ( _resolvedPadding ! . left , mainAxisExtent ) ;
mainAxisExtent + = child . size . height ;
assert ( child . parentData = = childParentData ) ;
child = childParentData . nextSibling ;
}
mainAxisExtent + = _resolvedPadding . bottom ;
mainAxisExtent + = _resolvedPadding ! . bottom ;
size = constraints . constrain ( Size ( constraints . maxWidth , mainAxisExtent ) ) ;
assert ( size . isFinite ) ;
@ -1061,7 +1029,8 @@ class RenderEditableContainerBox extends RenderBox
var child = firstChild ;
while ( child ! = null ) {
extent = math . max ( extent , childSize ( child ) ) ;
EditableContainerParentData childParentData = child . parentData ;
EditableContainerParentData childParentData =
child . parentData as EditableContainerParentData ;
child = childParentData . nextSibling ;
}
return extent ;
@ -1072,7 +1041,8 @@ class RenderEditableContainerBox extends RenderBox
var child = firstChild ;
while ( child ! = null ) {
extent + = childSize ( child ) ;
EditableContainerParentData childParentData = child . parentData ;
EditableContainerParentData childParentData =
child . parentData as EditableContainerParentData ;
child = childParentData . nextSibling ;
}
return extent ;
@ -1083,10 +1053,10 @@ class RenderEditableContainerBox extends RenderBox
_resolvePadding ( ) ;
return _getIntrinsicCrossAxis ( ( RenderBox child ) {
double childHeight = math . max (
0.0 , height - _resolvedPadding . top + _resolvedPadding . bottom ) ;
0.0 , height - _resolvedPadding ! . top + _resolvedPadding ! . bottom ) ;
return child . getMinIntrinsicWidth ( childHeight ) +
_resolvedPadding . left +
_resolvedPadding . right ;
_resolvedPadding ! . left +
_resolvedPadding ! . right ;
} ) ;
}
@ -1095,10 +1065,10 @@ class RenderEditableContainerBox extends RenderBox
_resolvePadding ( ) ;
return _getIntrinsicCrossAxis ( ( RenderBox child ) {
double childHeight = math . max (
0.0 , height - _resolvedPadding . top + _resolvedPadding . bottom ) ;
0.0 , height - _resolvedPadding ! . top + _resolvedPadding ! . bottom ) ;
return child . getMaxIntrinsicWidth ( childHeight ) +
_resolvedPadding . left +
_resolvedPadding . right ;
_resolvedPadding ! . left +
_resolvedPadding ! . right ;
} ) ;
}
@ -1106,11 +1076,11 @@ class RenderEditableContainerBox extends RenderBox
double computeMinIntrinsicHeight ( double width ) {
_resolvePadding ( ) ;
return _getIntrinsicMainAxis ( ( RenderBox child ) {
double childWidth =
math . max ( 0.0 , width - _resolvedPadding . left + _resolvedPadding . right ) ;
double childWidth = math . max (
0.0 , width - _resolvedPadding ! . left + _resolvedPadding ! . right ) ;
return child . getMinIntrinsicHeight ( childWidth ) +
_resolvedPadding . top +
_resolvedPadding . bottom ;
_resolvedPadding ! . top +
_resolvedPadding ! . bottom ;
} ) ;
}
@ -1118,18 +1088,18 @@ class RenderEditableContainerBox extends RenderBox
double computeMaxIntrinsicHeight ( double width ) {
_resolvePadding ( ) ;
return _getIntrinsicMainAxis ( ( RenderBox child ) {
final childWidth =
math . max ( 0.0 , width - _resolvedPadding . left + _resolvedPadding . right ) ;
final childWidth = math . max (
0.0 , width - _resolvedPadding ! . left + _resolvedPadding ! . right ) ;
return child . getMaxIntrinsicHeight ( childWidth ) +
_resolvedPadding . top +
_resolvedPadding . bottom ;
_resolvedPadding ! . top +
_resolvedPadding ! . bottom ;
} ) ;
}
@ override
double computeDistanceToActualBaseline ( TextBaseline baseline ) {
_resolvePadding ( ) ;
return defaultComputeDistanceToFirstActualBaseline ( baseline ) +
_resolvedPadding . top ;
return defaultComputeDistanceToFirstActualBaseline ( baseline ) ! +
_resolvedPadding ! . top ;
}
}