Prefer int literals

pull/145/head
Till Friebe 4 years ago
parent 32b6c9169a
commit 5c18ca1dc3
  1. 1
      analysis_options.yaml
  2. 2
      lib/widgets/cursor.dart
  3. 50
      lib/widgets/default_styles.dart
  4. 24
      lib/widgets/editor.dart
  5. 6
      lib/widgets/proxy.dart
  6. 4
      lib/widgets/raw_editor.dart
  7. 16
      lib/widgets/text_block.dart
  8. 22
      lib/widgets/text_line.dart
  9. 2
      lib/widgets/text_selection.dart
  10. 6
      lib/widgets/toolbar.dart

@ -25,6 +25,7 @@ linter:
- prefer_final_in_for_each
- prefer_final_locals
- prefer_initializing_formals
- prefer_int_literals
- prefer_relative_imports
- prefer_single_quotes
- unnecessary_parenthesis

@ -176,7 +176,7 @@ class CursorPainter {
}
if (caretRect.left < 0.0) {
caretRect = caretRect.shift(Offset(-caretRect.left, 0.0));
caretRect = caretRect.shift(Offset(-caretRect.left, 0));
}
final caretHeight = editable!.getFullHeightForCaret(position);

@ -87,10 +87,10 @@ class DefaultStyles {
final themeData = Theme.of(context);
final defaultTextStyle = DefaultTextStyle.of(context);
final baseStyle = defaultTextStyle.style.copyWith(
fontSize: 16.0,
fontSize: 16,
height: 1.3,
);
const baseSpacing = Tuple2<double, double>(6.0, 0);
const baseSpacing = Tuple2<double, double>(6, 0);
String fontFamily;
switch (themeData.platform) {
case TargetPlatform.iOS:
@ -110,36 +110,36 @@ class DefaultStyles {
return DefaultStyles(
h1: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith(
fontSize: 34.0,
fontSize: 34,
color: defaultTextStyle.style.color!.withOpacity(0.70),
height: 1.15,
fontWeight: FontWeight.w300,
),
const Tuple2(16.0, 0.0),
const Tuple2(0.0, 0.0),
const Tuple2(16, 0),
const Tuple2(0, 0),
null),
h2: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith(
fontSize: 24.0,
fontSize: 24,
color: defaultTextStyle.style.color!.withOpacity(0.70),
height: 1.15,
fontWeight: FontWeight.normal,
),
const Tuple2(8.0, 0.0),
const Tuple2(0.0, 0.0),
const Tuple2(8, 0),
const Tuple2(0, 0),
null),
h3: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith(
fontSize: 20.0,
fontSize: 20,
color: defaultTextStyle.style.color!.withOpacity(0.70),
height: 1.25,
fontWeight: FontWeight.w500,
),
const Tuple2(8.0, 0.0),
const Tuple2(0.0, 0.0),
const Tuple2(8, 0),
const Tuple2(0, 0),
null),
paragraph: DefaultTextBlockStyle(
baseStyle, const Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0), null),
baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null),
bold: const TextStyle(fontWeight: FontWeight.bold),
italic: const TextStyle(fontStyle: FontStyle.italic),
underline: const TextStyle(decoration: TextDecoration.underline),
@ -150,19 +150,19 @@ class DefaultStyles {
),
placeHolder: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith(
fontSize: 20.0,
fontSize: 20,
height: 1.5,
color: Colors.grey.withOpacity(0.6),
),
const Tuple2(0.0, 0.0),
const Tuple2(0.0, 0.0),
const Tuple2(0, 0),
const Tuple2(0, 0),
null),
lists: DefaultTextBlockStyle(
baseStyle, baseSpacing, const Tuple2(0.0, 6.0), null),
baseStyle, baseSpacing, const Tuple2(0, 6), null),
quote: DefaultTextBlockStyle(
TextStyle(color: baseStyle.color!.withOpacity(0.6)),
baseSpacing,
const Tuple2(6.0, 2.0),
const Tuple2(6, 2),
BoxDecoration(
border: Border(
left: BorderSide(width: 4, color: Colors.grey.shade300),
@ -172,24 +172,24 @@ class DefaultStyles {
TextStyle(
color: Colors.blue.shade900.withOpacity(0.9),
fontFamily: fontFamily,
fontSize: 13.0,
fontSize: 13,
height: 1.15,
),
baseSpacing,
const Tuple2(0.0, 0.0),
const Tuple2(0, 0),
BoxDecoration(
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(2),
)),
indent: DefaultTextBlockStyle(
baseStyle, baseSpacing, const Tuple2(0.0, 6.0), null),
baseStyle, baseSpacing, const Tuple2(0, 6), null),
align: DefaultTextBlockStyle(
baseStyle, const Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0), null),
baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null),
leading: DefaultTextBlockStyle(
baseStyle, const Tuple2(0.0, 0.0), const Tuple2(0.0, 0.0), null),
sizeSmall: const TextStyle(fontSize: 10.0),
sizeLarge: const TextStyle(fontSize: 18.0),
sizeHuge: const TextStyle(fontSize: 22.0));
baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null),
sizeSmall: const TextStyle(fontSize: 10),
sizeLarge: const TextStyle(fontSize: 18),
sizeHuge: const TextStyle(fontSize: 22));
}
DefaultStyles merge(DefaultStyles other) {

@ -220,7 +220,7 @@ class _QuillEditorState extends State<QuillEditor>
selectionTheme.cursorColor ?? cupertinoTheme.primaryColor;
selectionColor = selectionTheme.selectionColor ??
cupertinoTheme.primaryColor.withOpacity(0.40);
cursorRadius ??= const Radius.circular(2.0);
cursorRadius ??= const Radius.circular(2);
cursorOffset = Offset(
iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0);
break;
@ -252,7 +252,7 @@ class _QuillEditorState extends State<QuillEditor>
CursorStyle(
color: cursorColor,
backgroundColor: Colors.grey,
width: 2.0,
width: 2,
radius: cursorRadius,
offset: cursorOffset,
paintAboveText: paintCursorAboveText,
@ -580,7 +580,7 @@ class RenderEditor extends RenderEditableContainerBox
final parentData = child.parentData as BoxParentData;
return <TextSelectionPoint>[
TextSelectionPoint(
Offset(0.0, child.preferredLineHeight(localPosition)) +
Offset(0, child.preferredLineHeight(localPosition)) +
localOffset +
parentData.offset,
null)
@ -853,7 +853,7 @@ class RenderEditor extends RenderEditableContainerBox
if (dy == null) {
return null;
}
return math.max(dy, 0.0);
return math.max(dy, 0);
}
}
@ -1020,8 +1020,8 @@ class RenderEditableContainerBox extends RenderBox
double computeMinIntrinsicWidth(double height) {
_resolvePadding();
return _getIntrinsicCrossAxis((child) {
final childHeight = math.max(
0.0, height - _resolvedPadding!.top + _resolvedPadding!.bottom);
final childHeight = math.max<double>(
0, height - _resolvedPadding!.top + _resolvedPadding!.bottom);
return child.getMinIntrinsicWidth(childHeight) +
_resolvedPadding!.left +
_resolvedPadding!.right;
@ -1032,8 +1032,8 @@ class RenderEditableContainerBox extends RenderBox
double computeMaxIntrinsicWidth(double height) {
_resolvePadding();
return _getIntrinsicCrossAxis((child) {
final childHeight = math.max(
0.0, height - _resolvedPadding!.top + _resolvedPadding!.bottom);
final childHeight = math.max<double>(
0, height - _resolvedPadding!.top + _resolvedPadding!.bottom);
return child.getMaxIntrinsicWidth(childHeight) +
_resolvedPadding!.left +
_resolvedPadding!.right;
@ -1044,8 +1044,8 @@ class RenderEditableContainerBox extends RenderBox
double computeMinIntrinsicHeight(double width) {
_resolvePadding();
return _getIntrinsicMainAxis((child) {
final childWidth = math.max(
0.0, width - _resolvedPadding!.left + _resolvedPadding!.right);
final childWidth = math.max<double>(
0, width - _resolvedPadding!.left + _resolvedPadding!.right);
return child.getMinIntrinsicHeight(childWidth) +
_resolvedPadding!.top +
_resolvedPadding!.bottom;
@ -1056,8 +1056,8 @@ class RenderEditableContainerBox extends RenderBox
double computeMaxIntrinsicHeight(double width) {
_resolvePadding();
return _getIntrinsicMainAxis((child) {
final childWidth = math.max(
0.0, width - _resolvedPadding!.left + _resolvedPadding!.right);
final childWidth = math.max<double>(
0, width - _resolvedPadding!.left + _resolvedPadding!.right);
return child.getMaxIntrinsicHeight(childWidth) +
_resolvedPadding!.top +
_resolvedPadding!.bottom;

@ -87,14 +87,14 @@ class RenderEmbedProxy extends RenderProxyBox implements RenderContentProxyBox {
List<TextBox> getBoxesForSelection(TextSelection selection) {
if (!selection.isCollapsed) {
return <TextBox>[
TextBox.fromLTRBD(0.0, 0.0, size.width, size.height, TextDirection.ltr)
TextBox.fromLTRBD(0, 0, size.width, size.height, TextDirection.ltr)
];
}
final left = selection.extentOffset == 0 ? 0.0 : size.width;
final right = selection.extentOffset == 0 ? 0.0 : size.width;
return <TextBox>[
TextBox.fromLTRBD(left, 0.0, right, size.height, TextDirection.ltr)
TextBox.fromLTRBD(left, 0, right, size.height, TextDirection.ltr)
];
}
@ -104,7 +104,7 @@ class RenderEmbedProxy extends RenderProxyBox implements RenderContentProxyBox {
@override
Offset getOffsetForCaret(TextPosition position, Rect? caretPrototype) {
assert(position.offset <= 1 && position.offset >= 0);
return position.offset == 0 ? Offset.zero : Offset(size.width, 0.0);
return position.offset == 0 ? Offset.zero : Offset(size.width, 0);
}
@override

@ -596,7 +596,7 @@ class RawEditorState extends EditorState
widget.enableInteractiveSelection,
_hasFocus,
attrs.containsKey(Attribute.codeBlock.key)
? const EdgeInsets.all(16.0)
? const EdgeInsets.all(16)
: null,
widget.embedBuilder,
_cursorCont,
@ -988,7 +988,7 @@ class RawEditorState extends EditorState
final viewport = RenderAbstractViewport.of(getRenderEditor())!;
final editorOffset = getRenderEditor()!
.localToGlobal(const Offset(0.0, 0.0), ancestor: viewport);
.localToGlobal(const Offset(0, 0), ancestor: viewport);
final offsetInViewport = _scrollController!.offset + editorOffset.dy;
final offset = getRenderEditor()!.getOffsetToRevealCursor(

@ -142,8 +142,8 @@ class EditableTextBlock extends StatelessWidget {
count: count,
style: defaultStyles!.leading!.style,
attrs: attrs,
width: 32.0,
padding: 8.0,
width: 32,
padding: 8,
);
}
@ -172,9 +172,9 @@ class EditableTextBlock extends StatelessWidget {
count: count,
style: defaultStyles!.code!.style
.copyWith(color: defaultStyles.code!.style.color!.withOpacity(0.4)),
width: 32.0,
width: 32,
attrs: attrs,
padding: 16.0,
padding: 16,
withDot: false,
);
}
@ -419,7 +419,7 @@ class RenderEditableTextBlock extends RenderEditableContainerBox
TextSelectionPoint getBaseEndpointForSelection(TextSelection selection) {
if (selection.isCollapsed) {
return TextSelectionPoint(
Offset(0.0, preferredLineHeight(selection.extent)) +
Offset(0, preferredLineHeight(selection.extent)) +
getOffsetForCaret(selection.extent),
null);
}
@ -445,7 +445,7 @@ class RenderEditableTextBlock extends RenderEditableContainerBox
TextSelectionPoint getExtentEndpointForSelection(TextSelection selection) {
if (selection.isCollapsed) {
return TextSelectionPoint(
Offset(0.0, preferredLineHeight(selection.extent)) +
Offset(0, preferredLineHeight(selection.extent)) +
getOffsetForCaret(selection.extent),
null);
}
@ -666,7 +666,7 @@ class _BulletPoint extends StatelessWidget {
return Container(
alignment: AlignmentDirectional.topEnd,
width: width,
padding: const EdgeInsetsDirectional.only(end: 13.0),
padding: const EdgeInsetsDirectional.only(end: 13),
child: Text('', style: style),
);
}
@ -707,7 +707,7 @@ class __CheckboxState extends State<_Checkbox> {
return Container(
alignment: AlignmentDirectional.topEnd,
width: widget.width,
padding: const EdgeInsetsDirectional.only(end: 13.0),
padding: const EdgeInsetsDirectional.only(end: 13),
child: Checkbox(
value: widget.isChecked,
onChanged: _onCheckboxClicked,

@ -57,7 +57,7 @@ class TextLine extends StatelessWidget {
textSpan.style!,
textAlign,
textDirection!,
1.0,
1,
Localizations.localeOf(context),
strutStyle,
TextWidthBasis.parent,
@ -458,7 +458,7 @@ class RenderEditableTextLine extends RenderEditableBox {
TextSelection textSelection, bool first) {
if (textSelection.isCollapsed) {
return TextSelectionPoint(
Offset(0.0, preferredLineHeight(textSelection.extent)) +
Offset(0, preferredLineHeight(textSelection.extent)) +
getOffsetForCaret(textSelection.extent),
null);
}
@ -473,7 +473,7 @@ class RenderEditableTextLine extends RenderEditableBox {
@override
TextRange getLineBoundary(TextPosition position) {
final lineDy = getOffsetForCaret(position)
.translate(0.0, 0.5 * preferredLineHeight(position))
.translate(0, 0.5 * preferredLineHeight(position))
.dy;
final lineBoxes =
_getBoxes(TextSelection(baseOffset: 0, extentOffset: line.length - 1))
@ -543,15 +543,13 @@ class RenderEditableTextLine extends RenderEditableBox {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
_caretPrototype =
Rect.fromLTWH(0.0, 0.0, cursorWidth, cursorHeight + 2);
_caretPrototype = Rect.fromLTWH(0, 0, cursorWidth, cursorHeight + 2);
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
_caretPrototype =
Rect.fromLTWH(0.0, 2.0, cursorWidth, cursorHeight - 4.0);
_caretPrototype = Rect.fromLTWH(0, 2, cursorWidth, cursorHeight - 4.0);
break;
default:
throw 'Invalid platform';
@ -619,7 +617,7 @@ class RenderEditableTextLine extends RenderEditableBox {
: _leading!.getMinIntrinsicWidth(height - verticalPadding) as int;
final bodyWidth = _body == null
? 0
: _body!.getMinIntrinsicWidth(math.max(0.0, height - verticalPadding))
: _body!.getMinIntrinsicWidth(math.max(0, height - verticalPadding))
as int;
return horizontalPadding + leadingWidth + bodyWidth;
}
@ -634,7 +632,7 @@ class RenderEditableTextLine extends RenderEditableBox {
: _leading!.getMaxIntrinsicWidth(height - verticalPadding) as int;
final bodyWidth = _body == null
? 0
: _body!.getMaxIntrinsicWidth(math.max(0.0, height - verticalPadding))
: _body!.getMaxIntrinsicWidth(math.max(0, height - verticalPadding))
as int;
return horizontalPadding + leadingWidth + bodyWidth;
}
@ -646,7 +644,7 @@ class RenderEditableTextLine extends RenderEditableBox {
final verticalPadding = _resolvedPadding!.top + _resolvedPadding!.bottom;
if (_body != null) {
return _body!
.getMinIntrinsicHeight(math.max(0.0, width - horizontalPadding)) +
.getMinIntrinsicHeight(math.max(0, width - horizontalPadding)) +
verticalPadding;
}
return verticalPadding;
@ -659,7 +657,7 @@ class RenderEditableTextLine extends RenderEditableBox {
final verticalPadding = _resolvedPadding!.top + _resolvedPadding!.bottom;
if (_body != null) {
return _body!
.getMaxIntrinsicHeight(math.max(0.0, width - horizontalPadding)) +
.getMaxIntrinsicHeight(math.max(0, width - horizontalPadding)) +
verticalPadding;
}
return verticalPadding;
@ -704,7 +702,7 @@ class RenderEditableTextLine extends RenderEditableBox {
maxHeight: _body!.size.height);
_leading!.layout(leadingConstraints, parentUsesSize: true);
(_leading!.parentData as BoxParentData).offset =
Offset(0.0, _resolvedPadding!.top);
Offset(0, _resolvedPadding!.top);
}
size = constraints.constrain(Size(

@ -99,7 +99,7 @@ class EditorTextSelectionOverlay {
toolbar = OverlayEntry(builder: _buildToolbar);
Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor)!
.insert(toolbar!);
_toolbarController.forward(from: 0.0);
_toolbarController.forward(from: 0);
}
Widget _buildHandle(

@ -14,7 +14,7 @@ import '../models/documents/style.dart';
import '../utils/color.dart';
import 'controller.dart';
double iconSize = 18.0;
double iconSize = 18;
double kToolbarHeight = iconSize * 2;
typedef OnImagePickCallback = Future<String> Function(File file);
@ -464,7 +464,7 @@ Widget _selectHeadingStyleButtonBuilder(BuildContext context, Attribute? value,
child: RawMaterialButton(
hoverElevation: 0,
highlightElevation: 0,
elevation: 0.0,
elevation: 0,
visualDensity: VisualDensity.compact,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)),
@ -1265,7 +1265,7 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> {
return ConstrainedBox(
constraints: const BoxConstraints.tightFor(width: 110),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: [
widget.child,

Loading…
Cancel
Save