Merge branch 'master' of github.com:singerdmx/flutter-quill into prefer-const-constructors-in-immutables

pull/117/head
Till Friebe 4 years ago
commit 1729d8e5ec
  1. 3
      analysis_options.yaml
  2. 1
      example/lib/pages/home_page.dart
  3. 1
      example/lib/pages/read_only_page.dart
  4. 6
      lib/models/documents/document.dart
  5. 2
      lib/models/documents/history.dart
  6. 4
      lib/models/quill_delta.dart
  7. 2
      lib/models/rules/insert.dart
  8. 30
      lib/models/rules/rule.dart
  9. 8
      lib/widgets/controller.dart
  10. 10
      lib/widgets/cursor.dart
  11. 46
      lib/widgets/default_styles.dart
  12. 13
      lib/widgets/editor.dart
  13. 2
      lib/widgets/proxy.dart
  14. 35
      lib/widgets/raw_editor.dart
  15. 12
      lib/widgets/responsive_widget.dart
  16. 17
      lib/widgets/text_block.dart
  17. 24
      lib/widgets/text_line.dart
  18. 23
      lib/widgets/text_selection.dart
  19. 167
      lib/widgets/toolbar.dart

@ -7,5 +7,8 @@ analyzer:
unsafe_html: ignore unsafe_html: ignore
linter: linter:
rules: rules:
- always_put_required_named_parameters_first
- avoid_print - avoid_print
- avoid_redundant_argument_values
- prefer_const_constructors
- prefer_const_constructors_in_immutables - prefer_const_constructors_in_immutables

@ -110,7 +110,6 @@ class _HomePageState extends State<HomePage> {
autoFocus: false, autoFocus: false,
readOnly: false, readOnly: false,
placeholder: 'Add content', placeholder: 'Add content',
enableInteractiveSelection: true,
expands: false, expands: false,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
customStyles: DefaultStyles( customStyles: DefaultStyles(

@ -42,7 +42,6 @@ class _ReadOnlyPageState extends State<ReadOnlyPage> {
focusNode: _focusNode, focusNode: _focusNode,
autoFocus: true, autoFocus: true,
readOnly: !_edit, readOnly: !_edit,
enableInteractiveSelection: true,
expands: false, expands: false,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
), ),

@ -183,7 +183,7 @@ class Document {
bool nextOpIsImage = bool nextOpIsImage =
i + 1 < ops.length && ops[i + 1].isInsert && ops[i + 1].data is! String; i + 1 < ops.length && ops[i + 1].isInsert && ops[i + 1].data is! String;
if (nextOpIsImage && !(op.data as String).endsWith('\n')) { if (nextOpIsImage && !(op.data as String).endsWith('\n')) {
res.push(Operation.insert('\n', null)); res.push(Operation.insert('\n'));
} }
// Currently embed is equivalent to image and hence `is! String` // Currently embed is equivalent to image and hence `is! String`
bool opInsertImage = op.isInsert && op.data is! String; bool opInsertImage = op.isInsert && op.data is! String;
@ -193,7 +193,7 @@ class Document {
(ops[i + 1].data as String).startsWith('\n'); (ops[i + 1].data as String).startsWith('\n');
if (opInsertImage && (i + 1 == ops.length - 1 || !nextOpIsLineBreak)) { if (opInsertImage && (i + 1 == ops.length - 1 || !nextOpIsLineBreak)) {
// automatically append '\n' for image // automatically append '\n' for image
res.push(Operation.insert('\n', null)); res.push(Operation.insert('\n'));
} }
} }
@ -213,7 +213,7 @@ class Document {
_history.clear(); _history.clear();
} }
String toPlainText() => _root.children.map((e) => e.toPlainText()).join(''); String toPlainText() => _root.children.map((e) => e.toPlainText()).join();
void _loadDocument(Delta doc) { void _loadDocument(Delta doc) {
assert((doc.last.data as String).endsWith('\n')); assert((doc.last.data as String).endsWith('\n'));

@ -86,7 +86,7 @@ class History {
Tuple2 _change(Document doc, List<Delta> source, List<Delta> dest) { Tuple2 _change(Document doc, List<Delta> source, List<Delta> dest) {
if (source.isEmpty) { if (source.isEmpty) {
return Tuple2(false, 0); return const Tuple2(false, 0);
} }
Delta delta = source.removeLast(); Delta delta = source.removeLast();
// look for insert or delete // look for insert or delete

@ -294,7 +294,7 @@ class Delta {
if (other is! Delta) return false; if (other is! Delta) return false;
Delta typedOther = other; Delta typedOther = other;
final comparator = final comparator =
ListEquality<Operation>(const DefaultEquality<Operation>()); const ListEquality<Operation>(DefaultEquality<Operation>());
return comparator.equals(_operations, typedOther._operations); return comparator.equals(_operations, typedOther._operations);
} }
@ -520,7 +520,7 @@ class Delta {
if (op.isInsert) { if (op.isInsert) {
inverted.delete(op.length!); inverted.delete(op.length!);
} else if (op.isRetain && op.isPlain) { } else if (op.isRetain && op.isPlain) {
inverted.retain(op.length!, null); inverted.retain(op.length!);
baseIndex += op.length!; baseIndex += op.length!;
} else if (op.isDelete || (op.isRetain && op.isNotPlain)) { } else if (op.isDelete || (op.isRetain && op.isNotPlain)) {
final length = op.length!; final length = op.length!;

@ -378,5 +378,5 @@ Tuple2<Operation?, int?> _getNextNewLine(DeltaIterator iterator) {
return Tuple2(op, skipped); return Tuple2(op, skipped);
} }
} }
return Tuple2(null, null); return const Tuple2(null, null);
} }

@ -29,21 +29,21 @@ abstract class Rule {
class Rules { class Rules {
final List<Rule> _rules; final List<Rule> _rules;
static final Rules _instance = Rules([ static final Rules _instance = Rules([
FormatLinkAtCaretPositionRule(), const FormatLinkAtCaretPositionRule(),
ResolveLineFormatRule(), const ResolveLineFormatRule(),
ResolveInlineFormatRule(), const ResolveInlineFormatRule(),
InsertEmbedsRule(), const InsertEmbedsRule(),
ForceNewlineForInsertsAroundEmbedRule(), const ForceNewlineForInsertsAroundEmbedRule(),
AutoExitBlockRule(), const AutoExitBlockRule(),
PreserveBlockStyleOnInsertRule(), const PreserveBlockStyleOnInsertRule(),
PreserveLineStyleOnSplitRule(), const PreserveLineStyleOnSplitRule(),
ResetLineFormatOnNewLineRule(), const ResetLineFormatOnNewLineRule(),
AutoFormatLinksRule(), const AutoFormatLinksRule(),
PreserveInlineStylesRule(), const PreserveInlineStylesRule(),
CatchAllInsertRule(), const CatchAllInsertRule(),
EnsureEmbedLineRule(), const EnsureEmbedLineRule(),
PreserveLineStyleOnMergeRule(), const PreserveLineStyleOnMergeRule(),
CatchAllDeleteRule(), const CatchAllDeleteRule(),
]); ]);
Rules(this._rules); Rules(this._rules);

@ -18,7 +18,9 @@ class QuillController extends ChangeNotifier {
factory QuillController.basic() { factory QuillController.basic() {
return QuillController( return QuillController(
document: Document(), selection: TextSelection.collapsed(offset: 0)); document: Document(),
selection: const TextSelection.collapsed(offset: 0),
);
} }
// item1: Document state before [change]. // item1: Document state before [change].
@ -31,7 +33,6 @@ class QuillController extends ChangeNotifier {
TextEditingValue get plainTextEditingValue => TextEditingValue( TextEditingValue get plainTextEditingValue => TextEditingValue(
text: document.toPlainText(), text: document.toPlainText(),
selection: selection, selection: selection,
composing: TextRange.empty,
); );
Style getSelectionStyle() { Style getSelectionStyle() {
@ -73,7 +74,8 @@ class QuillController extends ChangeNotifier {
bool get hasRedo => document.hasRedo; bool get hasRedo => document.hasRedo;
void replaceText(int index, int len, Object? data, TextSelection? textSelection) { void replaceText(
int index, int len, Object? data, TextSelection? textSelection) {
assert(data is String || data is Embeddable); assert(data is String || data is Embeddable);
Delta? delta; Delta? delta;

@ -109,7 +109,8 @@ class CursorCont extends ChangeNotifier {
void _cursorWaitForStart(Timer timer) { void _cursorWaitForStart(Timer timer) {
_cursorTimer?.cancel(); _cursorTimer?.cancel();
_cursorTimer = Timer.periodic(Duration(milliseconds: 500), _cursorTick); _cursorTimer =
Timer.periodic(const Duration(milliseconds: 500), _cursorTick);
} }
void startCursorTimer() { void startCursorTimer() {
@ -117,10 +118,11 @@ class CursorCont extends ChangeNotifier {
_blinkOpacityCont.value = 1.0; _blinkOpacityCont.value = 1.0;
if (style.opacityAnimates) { if (style.opacityAnimates) {
_cursorTimer = _cursorTimer = Timer.periodic(
Timer.periodic(Duration(milliseconds: 150), _cursorWaitForStart); const Duration(milliseconds: 150), _cursorWaitForStart);
} else { } else {
_cursorTimer = Timer.periodic(Duration(milliseconds: 500), _cursorTick); _cursorTimer =
Timer.periodic(const Duration(milliseconds: 500), _cursorTick);
} }
} }

@ -6,9 +6,9 @@ class QuillStyles extends InheritedWidget {
final DefaultStyles data; final DefaultStyles data;
const QuillStyles({ const QuillStyles({
Key? key,
required this.data, required this.data,
required Widget child, required Widget child,
Key? key,
}) : super(key: key, child: child); }) : super(key: key, child: child);
@override @override
@ -86,7 +86,7 @@ class DefaultStyles {
fontSize: 16.0, fontSize: 16.0,
height: 1.3, height: 1.3,
); );
Tuple2<double, double> baseSpacing = Tuple2(6.0, 0); Tuple2<double, double> baseSpacing = const Tuple2(6.0, 0);
String fontFamily; String fontFamily;
switch (themeData.platform) { switch (themeData.platform) {
case TargetPlatform.iOS: case TargetPlatform.iOS:
@ -111,8 +111,8 @@ class DefaultStyles {
height: 1.15, height: 1.15,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
), ),
Tuple2(16.0, 0.0), const Tuple2(16.0, 0.0),
Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0),
null), null),
h2: DefaultTextBlockStyle( h2: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith( defaultTextStyle.style.copyWith(
@ -121,8 +121,8 @@ class DefaultStyles {
height: 1.15, height: 1.15,
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
), ),
Tuple2(8.0, 0.0), const Tuple2(8.0, 0.0),
Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0),
null), null),
h3: DefaultTextBlockStyle( h3: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith( defaultTextStyle.style.copyWith(
@ -131,15 +131,15 @@ class DefaultStyles {
height: 1.25, height: 1.25,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
), ),
Tuple2(8.0, 0.0), const Tuple2(8.0, 0.0),
Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0),
null), null),
paragraph: DefaultTextBlockStyle( paragraph: DefaultTextBlockStyle(
baseStyle, Tuple2(0.0, 0.0), Tuple2(0.0, 0.0), null), baseStyle, const Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0), null),
bold: TextStyle(fontWeight: FontWeight.bold), bold: const TextStyle(fontWeight: FontWeight.bold),
italic: TextStyle(fontStyle: FontStyle.italic), italic: const TextStyle(fontStyle: FontStyle.italic),
underline: TextStyle(decoration: TextDecoration.underline), underline: const TextStyle(decoration: TextDecoration.underline),
strikeThrough: TextStyle(decoration: TextDecoration.lineThrough), strikeThrough: const TextStyle(decoration: TextDecoration.lineThrough),
link: TextStyle( link: TextStyle(
color: themeData.accentColor, color: themeData.accentColor,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
@ -150,15 +150,15 @@ class DefaultStyles {
height: 1.5, height: 1.5,
color: Colors.grey.withOpacity(0.6), color: Colors.grey.withOpacity(0.6),
), ),
Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0),
Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0),
null), null),
lists: DefaultTextBlockStyle( lists: DefaultTextBlockStyle(
baseStyle, baseSpacing, Tuple2(0.0, 6.0), null), baseStyle, baseSpacing, const Tuple2(0.0, 6.0), null),
quote: DefaultTextBlockStyle( quote: DefaultTextBlockStyle(
TextStyle(color: baseStyle.color!.withOpacity(0.6)), TextStyle(color: baseStyle.color!.withOpacity(0.6)),
baseSpacing, baseSpacing,
Tuple2(6.0, 2.0), const Tuple2(6.0, 2.0),
BoxDecoration( BoxDecoration(
border: Border( border: Border(
left: BorderSide(width: 4, color: Colors.grey.shade300), left: BorderSide(width: 4, color: Colors.grey.shade300),
@ -172,18 +172,18 @@ class DefaultStyles {
height: 1.15, height: 1.15,
), ),
baseSpacing, baseSpacing,
Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0),
BoxDecoration( BoxDecoration(
color: Colors.grey.shade50, color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(2), borderRadius: BorderRadius.circular(2),
)), )),
indent: DefaultTextBlockStyle( indent: DefaultTextBlockStyle(
baseStyle, baseSpacing, Tuple2(0.0, 6.0), null), baseStyle, baseSpacing, const Tuple2(0.0, 6.0), null),
align: DefaultTextBlockStyle( align: DefaultTextBlockStyle(
baseStyle, Tuple2(0.0, 0.0), Tuple2(0.0, 0.0), null), baseStyle, const Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0), null),
sizeSmall: TextStyle(fontSize: 10.0), sizeSmall: const TextStyle(fontSize: 10.0),
sizeLarge: TextStyle(fontSize: 18.0), sizeLarge: const TextStyle(fontSize: 18.0),
sizeHuge: TextStyle(fontSize: 22.0)); sizeHuge: const TextStyle(fontSize: 22.0));
} }
DefaultStyles merge(DefaultStyles other) { DefaultStyles merge(DefaultStyles other) {

@ -176,14 +176,14 @@ class QuillEditor extends StatefulWidget {
required this.scrollable, required this.scrollable,
required this.padding, required this.padding,
required this.autoFocus, required this.autoFocus,
this.showCursor,
required this.readOnly, required this.readOnly,
required this.expands,
this.showCursor,
this.placeholder, this.placeholder,
this.enableInteractiveSelection = true, this.enableInteractiveSelection = true,
this.minHeight, this.minHeight,
this.maxHeight, this.maxHeight,
this.customStyles, this.customStyles,
required this.expands,
this.textCapitalization = TextCapitalization.sentences, this.textCapitalization = TextCapitalization.sentences,
this.keyboardAppearance = Brightness.light, this.keyboardAppearance = Brightness.light,
this.scrollPhysics, this.scrollPhysics,
@ -200,7 +200,6 @@ class QuillEditor extends StatefulWidget {
focusNode: FocusNode(), focusNode: FocusNode(),
autoFocus: true, autoFocus: true,
readOnly: readOnly, readOnly: readOnly,
enableInteractiveSelection: true,
expands: false, expands: false,
padding: EdgeInsets.zero); padding: EdgeInsets.zero);
} }
@ -726,8 +725,7 @@ class RenderEditor extends RenderEditableContainerBox
); );
if (position.offset - word.start <= 1) { if (position.offset - word.start <= 1) {
_handleSelectionChange( _handleSelectionChange(
TextSelection.collapsed( TextSelection.collapsed(offset: word.start),
offset: word.start, affinity: TextAffinity.downstream),
cause, cause,
); );
} else { } else {
@ -866,6 +864,11 @@ class RenderEditor extends RenderEditableContainerBox
); );
} }
/// Returns the y-offset of the editor at which [selection] is visible.
///
/// The offset is the distance from the top of the editor and is the minimum
/// from the current scroll position until [selection] becomes visible.
/// Returns null if [selection] is already visible.
double? getOffsetToRevealCursor( double? getOffsetToRevealCursor(
double viewportHeight, double scrollOffset, double offsetInViewport) { double viewportHeight, double scrollOffset, double offsetInViewport) {
List<TextSelectionPoint> endpoints = getEndpointsForSelection(selection); List<TextSelectionPoint> endpoints = getEndpointsForSelection(selection);

@ -113,7 +113,7 @@ class RenderEmbedProxy extends RenderProxyBox implements RenderContentProxyBox {
@override @override
TextRange getWordBoundary(TextPosition position) => TextRange getWordBoundary(TextPosition position) =>
TextRange(start: 0, end: 1); const TextRange(start: 0, end: 1);
@override @override
double getPreferredLineHeight() { double getPreferredLineHeight() {

@ -382,8 +382,6 @@ class RawEditorState extends EditorState
TextInputConfiguration( TextInputConfiguration(
inputType: TextInputType.multiline, inputType: TextInputType.multiline,
readOnly: widget.readOnly, readOnly: widget.readOnly,
obscureText: false,
autocorrect: true,
inputAction: TextInputAction.newline, inputAction: TextInputAction.newline,
keyboardAppearance: widget.keyboardAppearance, keyboardAppearance: widget.keyboardAppearance,
textCapitalization: widget.textCapitalization, textCapitalization: widget.textCapitalization,
@ -554,7 +552,7 @@ class RawEditorState extends EditorState
} }
BoxConstraints constraints = widget.expands BoxConstraints constraints = widget.expands
? BoxConstraints.expand() ? const BoxConstraints.expand()
: BoxConstraints( : BoxConstraints(
minHeight: widget.minHeight ?? 0.0, minHeight: widget.minHeight ?? 0.0,
maxHeight: widget.maxHeight ?? double.infinity); maxHeight: widget.maxHeight ?? double.infinity);
@ -602,7 +600,7 @@ class RawEditorState extends EditorState
widget.enableInteractiveSelection, widget.enableInteractiveSelection,
_hasFocus, _hasFocus,
attrs.containsKey(Attribute.codeBlock.key) attrs.containsKey(Attribute.codeBlock.key)
? EdgeInsets.all(16.0) ? const EdgeInsets.all(16.0)
: null, : null,
widget.embedBuilder, widget.embedBuilder,
_cursorCont, _cursorCont,
@ -702,6 +700,7 @@ class RawEditorState extends EditorState
_keyboardVisible = true; _keyboardVisible = true;
} else { } else {
_keyboardVisibilityController = KeyboardVisibilityController(); _keyboardVisibilityController = KeyboardVisibilityController();
_keyboardVisible = _keyboardVisibilityController!.isVisible;
_keyboardVisibilitySubscription = _keyboardVisibilitySubscription =
_keyboardVisibilityController?.onChange.listen((bool visible) { _keyboardVisibilityController?.onChange.listen((bool visible) {
_keyboardVisible = visible; _keyboardVisible = visible;
@ -817,7 +816,8 @@ class RawEditorState extends EditorState
String plainText = textEditingValue.text; String plainText = textEditingValue.text;
if (shortcut == InputShortcut.COPY) { if (shortcut == InputShortcut.COPY) {
if (!selection.isCollapsed) { if (!selection.isCollapsed) {
await Clipboard.setData(ClipboardData(text: selection.textInside(plainText))); await Clipboard.setData(
ClipboardData(text: selection.textInside(plainText)));
} }
return; return;
} }
@ -985,7 +985,7 @@ class RawEditorState extends EditorState
final viewport = RenderAbstractViewport.of(getRenderEditor())!; final viewport = RenderAbstractViewport.of(getRenderEditor())!;
final editorOffset = getRenderEditor()! final editorOffset = getRenderEditor()!
.localToGlobal(Offset(0.0, 0.0), ancestor: viewport); .localToGlobal(const Offset(0.0, 0.0), ancestor: viewport);
final offsetInViewport = _scrollController!.offset + editorOffset.dy; final offsetInViewport = _scrollController!.offset + editorOffset.dy;
final offset = getRenderEditor()!.getOffsetToRevealCursor( final offset = getRenderEditor()!.getOffsetToRevealCursor(
@ -997,7 +997,7 @@ class RawEditorState extends EditorState
if (offset != null) { if (offset != null) {
_scrollController!.animateTo( _scrollController!.animateTo(
offset, offset,
duration: Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
curve: Curves.fastOutSlowIn, curve: Curves.fastOutSlowIn,
); );
} }
@ -1151,16 +1151,17 @@ class _Editor extends MultiChildRenderObjectWidget {
@override @override
RenderEditor createRenderObject(BuildContext context) { RenderEditor createRenderObject(BuildContext context) {
return RenderEditor( return RenderEditor(
null, null,
textDirection, textDirection,
padding, padding,
document, document,
selection, selection,
hasFocus, hasFocus,
onSelectionChanged, onSelectionChanged,
startHandleLayerLink, startHandleLayerLink,
endHandleLayerLink, endHandleLayerLink,
EdgeInsets.fromLTRB(4, 4, 4, 5)); const EdgeInsets.fromLTRB(4, 4, 4, 5),
);
} }
@override @override

@ -5,12 +5,12 @@ class ResponsiveWidget extends StatelessWidget {
final Widget? mediumScreen; final Widget? mediumScreen;
final Widget? smallScreen; final Widget? smallScreen;
const ResponsiveWidget( const ResponsiveWidget({
{Key? key, required this.largeScreen,
required this.largeScreen, this.mediumScreen,
this.mediumScreen, this.smallScreen,
this.smallScreen}) Key? key,
: super(key: key); }) : super(key: key);
static bool isSmallScreen(BuildContext context) { static bool isSmallScreen(BuildContext context) {
return MediaQuery.of(context).size.width < 800; return MediaQuery.of(context).size.width < 800;

@ -84,7 +84,7 @@ class EditableTextBlock extends StatelessWidget {
block, block,
textDirection, textDirection,
verticalSpacing as Tuple2<double, double>, verticalSpacing as Tuple2<double, double>,
_getDecorationForBlock(block, defaultStyles) ?? BoxDecoration(), _getDecorationForBlock(block, defaultStyles) ?? const BoxDecoration(),
contentPadding, contentPadding,
_buildChildren(context, indentLevelCounts)); _buildChildren(context, indentLevelCounts));
} }
@ -253,11 +253,11 @@ class EditableTextBlock extends StatelessWidget {
class RenderEditableTextBlock extends RenderEditableContainerBox class RenderEditableTextBlock extends RenderEditableContainerBox
implements RenderEditableBox { implements RenderEditableBox {
RenderEditableTextBlock({ RenderEditableTextBlock({
List<RenderEditableBox>? children,
required Block block, required Block block,
required TextDirection textDirection, required TextDirection textDirection,
required EdgeInsetsGeometry padding, required EdgeInsetsGeometry padding,
required Decoration decoration, required Decoration decoration,
List<RenderEditableBox>? children,
ImageConfiguration configuration = ImageConfiguration.empty, ImageConfiguration configuration = ImageConfiguration.empty,
EdgeInsets contentPadding = EdgeInsets.zero, EdgeInsets contentPadding = EdgeInsets.zero,
}) : _decoration = decoration, }) : _decoration = decoration,
@ -402,7 +402,8 @@ class RenderEditableTextBlock extends RenderEditableContainerBox
} }
Offset caretOffset = child.getOffsetForCaret(childLocalPosition); Offset caretOffset = child.getOffsetForCaret(childLocalPosition);
Offset testOffset = sibling.getOffsetForCaret(TextPosition(offset: 0)); Offset testOffset =
sibling.getOffsetForCaret(const TextPosition(offset: 0));
Offset finalOffset = Offset(caretOffset.dx, testOffset.dy); Offset finalOffset = Offset(caretOffset.dx, testOffset.dy);
return TextPosition( return TextPosition(
offset: sibling.getContainer().getOffset() + offset: sibling.getContainer().getOffset() +
@ -558,7 +559,6 @@ class _NumberPoint extends StatelessWidget {
final double padding; final double padding;
const _NumberPoint({ const _NumberPoint({
Key? key,
required this.index, required this.index,
required this.indentLevelCounts, required this.indentLevelCounts,
required this.count, required this.count,
@ -567,6 +567,7 @@ class _NumberPoint extends StatelessWidget {
required this.attrs, required this.attrs,
this.withDot = true, this.withDot = true,
this.padding = 0.0, this.padding = 0.0,
Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -623,7 +624,7 @@ class _NumberPoint extends StatelessWidget {
n = (n / 26).floor(); n = (n / 26).floor();
} }
return result.toString().split('').reversed.join(''); return result.toString().split('').reversed.join();
} }
String _intToRoman(int input) { String _intToRoman(int input) {
@ -656,9 +657,9 @@ class _BulletPoint extends StatelessWidget {
final double width; final double width;
const _BulletPoint({ const _BulletPoint({
Key? key,
required this.style, required this.style,
required this.width, required this.width,
Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -666,7 +667,7 @@ class _BulletPoint extends StatelessWidget {
return Container( return Container(
alignment: AlignmentDirectional.topEnd, alignment: AlignmentDirectional.topEnd,
width: width, width: width,
padding: EdgeInsetsDirectional.only(end: 13.0), padding: const EdgeInsetsDirectional.only(end: 13.0),
child: Text('', style: style), child: Text('', style: style),
); );
} }
@ -707,7 +708,7 @@ class __CheckboxState extends State<_Checkbox> {
return Container( return Container(
alignment: AlignmentDirectional.topEnd, alignment: AlignmentDirectional.topEnd,
width: widget.width, width: widget.width,
padding: EdgeInsetsDirectional.only(end: 13.0), padding: const EdgeInsetsDirectional.only(end: 13.0),
child: Checkbox( child: Checkbox(
value: widget.isChecked, value: widget.isChecked,
onChanged: _onCheckboxClicked, onChanged: _onCheckboxClicked,

@ -27,13 +27,13 @@ class TextLine extends StatelessWidget {
final EmbedBuilder embedBuilder; final EmbedBuilder embedBuilder;
final DefaultStyles styles; final DefaultStyles styles;
const TextLine( const TextLine({
{Key? key, required this.line,
required this.line, required this.embedBuilder,
this.textDirection, required this.styles,
required this.embedBuilder, this.textDirection,
required this.styles}) Key? key,
: super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -87,7 +87,7 @@ class TextLine extends StatelessWidget {
.map((node) => _getTextSpanFromNode(defaultStyles, node)) .map((node) => _getTextSpanFromNode(defaultStyles, node))
.toList(growable: false); .toList(growable: false);
TextStyle textStyle = TextStyle(); TextStyle textStyle = const TextStyle();
if (line.style.containsKey(Attribute.placeholder.key)) { if (line.style.containsKey(Attribute.placeholder.key)) {
textStyle = defaultStyles.placeHolder!.style; textStyle = defaultStyles.placeHolder!.style;
@ -121,7 +121,7 @@ class TextLine extends StatelessWidget {
TextSpan _getTextSpanFromNode(DefaultStyles defaultStyles, Node node) { TextSpan _getTextSpanFromNode(DefaultStyles defaultStyles, Node node) {
leaf.Text textNode = node as leaf.Text; leaf.Text textNode = node as leaf.Text;
Style style = textNode.style; Style style = textNode.style;
TextStyle res = TextStyle(); TextStyle res = const TextStyle();
Map<String, TextStyle?> m = { Map<String, TextStyle?> m = {
Attribute.bold.key: defaultStyles.bold, Attribute.bold.key: defaultStyles.bold,
@ -534,7 +534,8 @@ class RenderEditableTextLine extends RenderEditableBox {
double get cursorWidth => cursorCont.style.width; double get cursorWidth => cursorCont.style.width;
double get cursorHeight => double get cursorHeight =>
cursorCont.style.height ?? preferredLineHeight(TextPosition(offset: 0)); cursorCont.style.height ??
preferredLineHeight(const TextPosition(offset: 0));
void _computeCaretPrototype() { void _computeCaretPrototype() {
switch (defaultTargetPlatform) { switch (defaultTargetPlatform) {
@ -839,7 +840,8 @@ class _TextLineElement extends RenderObjectElement {
} }
@override @override
void moveRenderObjectChild(RenderObject child, dynamic oldSlot, dynamic newSlot) { void moveRenderObjectChild(
RenderObject child, dynamic oldSlot, dynamic newSlot) {
throw UnimplementedError(); throw UnimplementedError();
} }

@ -58,7 +58,7 @@ class EditorTextSelectionOverlay {
OverlayState overlay = Overlay.of(context, rootOverlay: true)!; OverlayState overlay = Overlay.of(context, rootOverlay: true)!;
_toolbarController = AnimationController( _toolbarController = AnimationController(
duration: Duration(milliseconds: 150), vsync: overlay); duration: const Duration(milliseconds: 150), vsync: overlay);
} }
TextSelection get _selection => value.selection; TextSelection get _selection => value.selection;
@ -143,13 +143,14 @@ class EditorTextSelectionOverlay {
TextPosition textPosition; TextPosition textPosition;
switch (position) { switch (position) {
case _TextSelectionHandlePosition.START: case _TextSelectionHandlePosition.START:
textPosition = textPosition = newSelection != null
newSelection != null ? newSelection.base : TextPosition(offset: 0); ? newSelection.base
: const TextPosition(offset: 0);
break; break;
case _TextSelectionHandlePosition.END: case _TextSelectionHandlePosition.END:
textPosition = newSelection != null textPosition = newSelection != null
? newSelection.extent ? newSelection.extent
: TextPosition(offset: 0); : const TextPosition(offset: 0);
break; break;
default: default:
throw ('Invalid position'); throw ('Invalid position');
@ -198,7 +199,7 @@ class EditorTextSelectionOverlay {
endpoints, endpoints,
selectionDelegate, selectionDelegate,
clipboardStatus, clipboardStatus,
Offset(0, 0)), const Offset(0, 0)),
), ),
); );
} }
@ -245,7 +246,6 @@ class EditorTextSelectionOverlay {
class _TextSelectionHandleOverlay extends StatefulWidget { class _TextSelectionHandleOverlay extends StatefulWidget {
const _TextSelectionHandleOverlay({ const _TextSelectionHandleOverlay({
Key? key,
required this.selection, required this.selection,
required this.position, required this.position,
required this.startHandleLayerLink, required this.startHandleLayerLink,
@ -255,6 +255,7 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
required this.onSelectionHandleTapped, required this.onSelectionHandleTapped,
required this.selectionControls, required this.selectionControls,
this.dragStartBehavior = DragStartBehavior.start, this.dragStartBehavior = DragStartBehavior.start,
Key? key,
}) : super(key: key); }) : super(key: key);
final TextSelection selection; final TextSelection selection;
@ -292,8 +293,8 @@ class _TextSelectionHandleOverlayState
void initState() { void initState() {
super.initState(); super.initState();
_controller = _controller = AnimationController(
AnimationController(duration: Duration(milliseconds: 150), vsync: this); duration: const Duration(milliseconds: 150), vsync: this);
_handleVisibilityChanged(); _handleVisibilityChanged();
widget._visibility!.addListener(_handleVisibilityChanged); widget._visibility!.addListener(_handleVisibilityChanged);
@ -468,7 +469,7 @@ class _TextSelectionHandleOverlayState
class EditorTextSelectionGestureDetector extends StatefulWidget { class EditorTextSelectionGestureDetector extends StatefulWidget {
const EditorTextSelectionGestureDetector({ const EditorTextSelectionGestureDetector({
Key? key, required this.child,
this.onTapDown, this.onTapDown,
this.onForcePressStart, this.onForcePressStart,
this.onForcePressEnd, this.onForcePressEnd,
@ -482,7 +483,7 @@ class EditorTextSelectionGestureDetector extends StatefulWidget {
this.onDragSelectionUpdate, this.onDragSelectionUpdate,
this.onDragSelectionEnd, this.onDragSelectionEnd,
this.behavior, this.behavior,
required this.child, Key? key,
}) : super(key: key); }) : super(key: key);
final GestureTapDownCallback? onTapDown; final GestureTapDownCallback? onTapDown;
@ -579,7 +580,7 @@ class _EditorTextSelectionGestureDetectorState
void _handleDragUpdate(DragUpdateDetails details) { void _handleDragUpdate(DragUpdateDetails details) {
_lastDragUpdateDetails = details; _lastDragUpdateDetails = details;
_dragUpdateThrottleTimer ??= _dragUpdateThrottleTimer ??=
Timer(Duration(milliseconds: 50), _handleDragUpdateThrottled); Timer(const Duration(milliseconds: 50), _handleDragUpdateThrottled);
} }
void _handleDragUpdateThrottled() { void _handleDragUpdateThrottled() {

@ -25,9 +25,9 @@ class InsertEmbedButton extends StatelessWidget {
final IconData icon; final IconData icon;
const InsertEmbedButton({ const InsertEmbedButton({
Key? key,
required this.controller, required this.controller,
required this.icon, required this.icon,
Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -56,9 +56,9 @@ class LinkStyleButton extends StatefulWidget {
final IconData? icon; final IconData? icon;
const LinkStyleButton({ const LinkStyleButton({
Key? key,
required this.controller, required this.controller,
this.icon, this.icon,
Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -114,7 +114,7 @@ class _LinkStyleButtonState extends State<LinkStyleButton> {
showDialog<String>( showDialog<String>(
context: context, context: context,
builder: (ctx) { builder: (ctx) {
return _LinkDialog(); return const _LinkDialog();
}, },
).then(_linkSubmitted); ).then(_linkSubmitted);
} }
@ -141,14 +141,14 @@ class _LinkDialogState extends State<_LinkDialog> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
content: TextField( content: TextField(
decoration: InputDecoration(labelText: 'Paste a link'), decoration: const InputDecoration(labelText: 'Paste a link'),
autofocus: true, autofocus: true,
onChanged: _linkChanged, onChanged: _linkChanged,
), ),
actions: [ actions: [
TextButton( TextButton(
onPressed: _link.isNotEmpty ? _applyLink : null, onPressed: _link.isNotEmpty ? _applyLink : null,
child: Text('Apply'), child: const Text('Apply'),
), ),
], ],
); );
@ -183,11 +183,11 @@ class ToggleStyleButton extends StatefulWidget {
final ToggleStyleButtonBuilder childBuilder; final ToggleStyleButtonBuilder childBuilder;
const ToggleStyleButton({ const ToggleStyleButton({
Key? key,
required this.attribute, required this.attribute,
required this.icon, required this.icon,
required this.controller, required this.controller,
this.childBuilder = defaultToggleStyleButtonBuilder, this.childBuilder = defaultToggleStyleButtonBuilder,
Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -267,11 +267,11 @@ class ToggleCheckListButton extends StatefulWidget {
final Attribute attribute; final Attribute attribute;
const ToggleCheckListButton({ const ToggleCheckListButton({
Key? key,
required this.icon, required this.icon,
required this.controller, required this.controller,
this.childBuilder = defaultToggleStyleButtonBuilder,
required this.attribute, required this.attribute,
this.childBuilder = defaultToggleStyleButtonBuilder,
Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -371,7 +371,7 @@ Widget defaultToggleStyleButtonBuilder(
class SelectHeaderStyleButton extends StatefulWidget { class SelectHeaderStyleButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
const SelectHeaderStyleButton({Key? key, required this.controller}) const SelectHeaderStyleButton({required this.controller, Key? key})
: super(key: key); : super(key: key);
@override @override
@ -430,7 +430,7 @@ class _SelectHeaderStyleButtonState extends State<SelectHeaderStyleButton> {
Widget _selectHeadingStyleButtonBuilder(BuildContext context, Attribute? value, Widget _selectHeadingStyleButtonBuilder(BuildContext context, Attribute? value,
ValueChanged<Attribute?> onSelected) { ValueChanged<Attribute?> onSelected) {
final style = TextStyle(fontSize: 13); final style = const TextStyle(fontSize: 13);
final Map<Attribute, String> _valueToText = { final Map<Attribute, String> _valueToText = {
Attribute.header: 'Normal text', Attribute.header: 'Normal text',
@ -478,7 +478,7 @@ Widget _selectHeadingStyleButtonBuilder(BuildContext context, Attribute? value,
: (value.key == 'h2') : (value.key == 'h2')
? Attribute.h2 ? Attribute.h2
: Attribute.h3]!, : Attribute.h3]!,
style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600), style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600),
), ),
); );
} }
@ -494,14 +494,14 @@ class ImageButton extends StatefulWidget {
final ImageSource imageSource; final ImageSource imageSource;
const ImageButton( const ImageButton({
{Key? key, required this.icon,
required this.icon, required this.controller,
required this.controller, required this.imageSource,
required this.imageSource, this.onImagePickCallback,
this.onImagePickCallback, this.imagePickImpl,
this.imagePickImpl}) Key? key,
: super(key: key); }) : super(key: key);
@override @override
_ImageButtonState createState() => _ImageButtonState(); _ImageButtonState createState() => _ImageButtonState();
@ -525,7 +525,6 @@ class _ImageButtonState extends State<ImageButton> {
Future<String?> _pickImageWeb() async { Future<String?> _pickImageWeb() async {
_paths = (await FilePicker.platform.pickFiles( _paths = (await FilePicker.platform.pickFiles(
type: _pickingType, type: _pickingType,
allowMultiple: false,
allowedExtensions: (_extension?.isNotEmpty ?? false) allowedExtensions: (_extension?.isNotEmpty ?? false)
? _extension?.replaceAll(' ', '').split(',') ? _extension?.replaceAll(' ', '').split(',')
: null, : null,
@ -601,12 +600,12 @@ class ColorButton extends StatefulWidget {
final bool background; final bool background;
final QuillController controller; final QuillController controller;
const ColorButton( const ColorButton({
{Key? key, required this.icon,
required this.icon, required this.controller,
required this.controller, required this.background,
required this.background}) Key? key,
: super(key: key); }) : super(key: key);
@override @override
_ColorButtonState createState() => _ColorButtonState(); _ColorButtonState createState() => _ColorButtonState();
@ -726,7 +725,7 @@ class _ColorButtonState extends State<ColorButton> {
backgroundColor: Theme.of(context).canvasColor, backgroundColor: Theme.of(context).canvasColor,
content: SingleChildScrollView( content: SingleChildScrollView(
child: MaterialPicker( child: MaterialPicker(
pickerColor: Color(0x00000000), pickerColor: const Color(0x00000000),
onColorChanged: _changeColor, onColorChanged: _changeColor,
), ),
)), )),
@ -739,12 +738,12 @@ class HistoryButton extends StatefulWidget {
final bool undo; final bool undo;
final QuillController controller; final QuillController controller;
const HistoryButton( const HistoryButton({
{Key? key, required this.icon,
required this.icon, required this.controller,
required this.controller, required this.undo,
required this.undo}) Key? key,
: super(key: key); }) : super(key: key);
@override @override
_HistoryButtonState createState() => _HistoryButtonState(); _HistoryButtonState createState() => _HistoryButtonState();
@ -811,12 +810,12 @@ class IndentButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
final bool isIncrease; final bool isIncrease;
const IndentButton( const IndentButton({
{Key? key, required this.icon,
required this.icon, required this.controller,
required this.controller, required this.isIncrease,
required this.isIncrease}) Key? key,
: super(key: key); }) : super(key: key);
@override @override
_IndentButtonState createState() => _IndentButtonState(); _IndentButtonState createState() => _IndentButtonState();
@ -867,7 +866,7 @@ class ClearFormatButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
const ClearFormatButton( const ClearFormatButton(
{Key? key, required this.icon, required this.controller}) {required this.icon, required this.controller, Key? key,})
: super(key: key); : super(key: key);
@override @override
@ -898,30 +897,31 @@ class _ClearFormatButtonState extends State<ClearFormatButton> {
class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
final List<Widget> children; final List<Widget> children;
const QuillToolbar({Key? key, required this.children}) : super(key: key); const QuillToolbar({required this.children, Key? key}) : super(key: key);
factory QuillToolbar.basic( factory QuillToolbar.basic({
{Key? key, required QuillController controller,
required QuillController controller, double toolbarIconSize = 18.0,
double toolbarIconSize = 18.0, bool showBoldButton = true,
bool showBoldButton = true, bool showItalicButton = true,
bool showItalicButton = true, bool showUnderLineButton = true,
bool showUnderLineButton = true, bool showStrikeThrough = true,
bool showStrikeThrough = true, bool showColorButton = true,
bool showColorButton = true, bool showBackgroundColorButton = true,
bool showBackgroundColorButton = true, bool showClearFormat = true,
bool showClearFormat = true, bool showHeaderStyle = true,
bool showHeaderStyle = true, bool showListNumbers = true,
bool showListNumbers = true, bool showListBullets = true,
bool showListBullets = true, bool showListCheck = true,
bool showListCheck = true, bool showCodeBlock = true,
bool showCodeBlock = true, bool showQuote = true,
bool showQuote = true, bool showIndent = true,
bool showIndent = true, bool showLink = true,
bool showLink = true, bool showHistory = true,
bool showHistory = true, bool showHorizontalRule = false,
bool showHorizontalRule = false, OnImagePickCallback? onImagePickCallback,
OnImagePickCallback? onImagePickCallback}) { Key? key,
}) {
iconSize = toolbarIconSize; iconSize = toolbarIconSize;
return QuillToolbar(key: key, children: [ return QuillToolbar(key: key, children: [
Visibility( Visibility(
@ -940,7 +940,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
undo: false, undo: false,
), ),
), ),
SizedBox(width: 0.6), const SizedBox(width: 0.6),
Visibility( Visibility(
visible: showBoldButton, visible: showBoldButton,
child: ToggleStyleButton( child: ToggleStyleButton(
@ -949,7 +949,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
controller: controller, controller: controller,
), ),
), ),
SizedBox(width: 0.6), const SizedBox(width: 0.6),
Visibility( Visibility(
visible: showItalicButton, visible: showItalicButton,
child: ToggleStyleButton( child: ToggleStyleButton(
@ -958,7 +958,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
controller: controller, controller: controller,
), ),
), ),
SizedBox(width: 0.6), const SizedBox(width: 0.6),
Visibility( Visibility(
visible: showUnderLineButton, visible: showUnderLineButton,
child: ToggleStyleButton( child: ToggleStyleButton(
@ -967,7 +967,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
controller: controller, controller: controller,
), ),
), ),
SizedBox(width: 0.6), const SizedBox(width: 0.6),
Visibility( Visibility(
visible: showStrikeThrough, visible: showStrikeThrough,
child: ToggleStyleButton( child: ToggleStyleButton(
@ -976,7 +976,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
controller: controller, controller: controller,
), ),
), ),
SizedBox(width: 0.6), const SizedBox(width: 0.6),
Visibility( Visibility(
visible: showColorButton, visible: showColorButton,
child: ColorButton( child: ColorButton(
@ -985,7 +985,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
background: false, background: false,
), ),
), ),
SizedBox(width: 0.6), const SizedBox(width: 0.6),
Visibility( Visibility(
visible: showBackgroundColorButton, visible: showBackgroundColorButton,
child: ColorButton( child: ColorButton(
@ -994,7 +994,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
background: true, background: true,
), ),
), ),
SizedBox(width: 0.6), const SizedBox(width: 0.6),
Visibility( Visibility(
visible: showClearFormat, visible: showClearFormat,
child: ClearFormatButton( child: ClearFormatButton(
@ -1002,7 +1002,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
controller: controller, controller: controller,
), ),
), ),
SizedBox(width: 0.6), const SizedBox(width: 0.6),
Visibility( Visibility(
visible: onImagePickCallback != null, visible: onImagePickCallback != null,
child: ImageButton( child: ImageButton(
@ -1012,7 +1012,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
onImagePickCallback: onImagePickCallback, onImagePickCallback: onImagePickCallback,
), ),
), ),
SizedBox(width: 0.6), const SizedBox(width: 0.6),
Visibility( Visibility(
visible: onImagePickCallback != null, visible: onImagePickCallback != null,
child: ImageButton( child: ImageButton(
@ -1120,7 +1120,7 @@ class _QuillToolbarState extends State<QuillToolbar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric(horizontal: 8),
constraints: BoxConstraints.tightFor(height: widget.preferredSize.height), constraints: BoxConstraints.tightFor(height: widget.preferredSize.height),
color: Theme.of(context).canvasColor, color: Theme.of(context).canvasColor,
child: CustomScrollView( child: CustomScrollView(
@ -1148,13 +1148,13 @@ class QuillIconButton extends StatelessWidget {
final double highlightElevation; final double highlightElevation;
const QuillIconButton({ const QuillIconButton({
Key? key,
required this.onPressed, required this.onPressed,
this.icon, this.icon,
this.size = 40, this.size = 40,
this.fillColor, this.fillColor,
this.hoverElevation = 1, this.hoverElevation = 1,
this.highlightElevation = 1, this.highlightElevation = 1,
Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -1164,7 +1164,6 @@ class QuillIconButton extends StatelessWidget {
child: RawMaterialButton( child: RawMaterialButton(
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)),
padding: EdgeInsets.zero,
fillColor: fillColor, fillColor: fillColor,
elevation: 0, elevation: 0,
hoverElevation: hoverElevation, hoverElevation: hoverElevation,
@ -1187,15 +1186,15 @@ class QuillDropdownButton<T> extends StatefulWidget {
final ValueChanged<T> onSelected; final ValueChanged<T> onSelected;
const QuillDropdownButton({ const QuillDropdownButton({
Key? key,
this.height = 40,
this.fillColor,
this.hoverElevation = 1,
this.highlightElevation = 1,
required this.child, required this.child,
required this.initialValue, required this.initialValue,
required this.items, required this.items,
required this.onSelected, required this.onSelected,
this.height = 40,
this.fillColor,
this.hoverElevation = 1,
this.highlightElevation = 1,
Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -1210,7 +1209,6 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> {
child: RawMaterialButton( child: RawMaterialButton(
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)),
padding: EdgeInsets.zero,
fillColor: widget.fillColor, fillColor: widget.fillColor,
elevation: 0, elevation: 0,
hoverElevation: widget.hoverElevation, hoverElevation: widget.hoverElevation,
@ -1251,19 +1249,20 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> {
// if (widget.onCanceled != null) widget.onCanceled(); // if (widget.onCanceled != null) widget.onCanceled();
return null; return null;
} }
widget.onSelected(newValue);
}); });
} }
Widget _buildContent(BuildContext context) { Widget _buildContent(BuildContext context) {
return ConstrainedBox( return ConstrainedBox(
constraints: BoxConstraints.tightFor(width: 110), constraints: const BoxConstraints.tightFor(width: 110),
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row( child: Row(
children: [ children: [
widget.child, widget.child,
Expanded(child: Container()), Expanded(child: Container()),
Icon(Icons.arrow_drop_down, size: 15) const Icon(Icons.arrow_drop_down, size: 15)
], ],
), ),
), ),

Loading…
Cancel
Save