Prefer const constructors (#116)

pull/117/head^2
Till Friebe 4 years ago committed by GitHub
parent 1cf37c1824
commit d6b21586a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      analysis_options.yaml
  2. 2
      lib/models/documents/history.dart
  3. 2
      lib/models/quill_delta.dart
  4. 2
      lib/models/rules/insert.dart
  5. 30
      lib/models/rules/rule.dart
  6. 7
      lib/widgets/controller.dart
  7. 10
      lib/widgets/cursor.dart
  8. 44
      lib/widgets/default_styles.dart
  9. 2
      lib/widgets/proxy.dart
  10. 14
      lib/widgets/raw_editor.dart
  11. 9
      lib/widgets/text_block.dart
  12. 7
      lib/widgets/text_line.dart
  13. 17
      lib/widgets/text_selection.dart
  14. 36
      lib/widgets/toolbar.dart

@ -10,3 +10,4 @@ linter:
- always_put_required_named_parameters_first - always_put_required_named_parameters_first
- avoid_print - avoid_print
- avoid_redundant_argument_values - avoid_redundant_argument_values
- prefer_const_constructors

@ -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);
} }

@ -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].
@ -72,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);
} }
} }

@ -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) {

@ -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() {

@ -552,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);
@ -600,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,
@ -816,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;
} }
@ -984,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(
@ -996,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,
); );
} }
@ -1159,7 +1160,8 @@ class _Editor extends MultiChildRenderObjectWidget {
onSelectionChanged, onSelectionChanged,
startHandleLayerLink, startHandleLayerLink,
endHandleLayerLink, endHandleLayerLink,
EdgeInsets.fromLTRB(4, 4, 4, 5)); const EdgeInsets.fromLTRB(4, 4, 4, 5),
);
} }
@override @override

@ -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));
} }
@ -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() +
@ -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,

@ -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) {

@ -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)),
), ),
); );
} }
@ -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);
@ -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() {

@ -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'),
), ),
], ],
); );
@ -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),
), ),
); );
} }
@ -725,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,
), ),
)), )),
@ -939,7 +939,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(
@ -948,7 +948,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(
@ -957,7 +957,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(
@ -966,7 +966,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(
@ -975,7 +975,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(
@ -984,7 +984,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(
@ -993,7 +993,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(
@ -1001,7 +1001,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(
@ -1011,7 +1011,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(
@ -1119,7 +1119,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(
@ -1254,14 +1254,14 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> {
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