ref: add `VerticalSpacing.zero` and `HorizontalSpacing.zero` named constants (#2083)

* feat: add named constants to HorizontalSpacing/VerticalSpacing

* ref: use VerticalSpacing.zero across code
pull/2086/head v10.1.5
Adil Hanney 8 months ago committed by GitHub
parent 9a7421a53b
commit e11af21fba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      example/lib/screens/quill/my_quill_editor.dart
  2. 2
      lib/src/common/structs/horizontal_spacing.dart
  3. 2
      lib/src/common/structs/vertical_spacing.dart
  4. 4
      lib/src/editor/raw_editor/raw_editor_state.dart
  5. 46
      lib/src/editor/widgets/default_styles.dart

@ -54,9 +54,9 @@ class MyQuillEditor extends StatelessWidget {
height: 1.15, height: 1.15,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
), ),
const HorizontalSpacing(0, 0), HorizontalSpacing.zero,
const VerticalSpacing(16, 0), const VerticalSpacing(16, 0),
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
sizeSmall: defaultTextStyle.style.copyWith(fontSize: 9), sizeSmall: defaultTextStyle.style.copyWith(fontSize: 9),

@ -9,4 +9,6 @@ class HorizontalSpacing {
final double left; final double left;
final double right; final double right;
static const zero = HorizontalSpacing(0, 0);
} }

@ -9,4 +9,6 @@ class VerticalSpacing {
final double top; final double top;
final double bottom; final double bottom;
static const zero = VerticalSpacing(0, 0);
} }

@ -1145,7 +1145,7 @@ class QuillRawEditorState extends EditorState
} else if (attrs.containsKey(Attribute.align.key)) { } else if (attrs.containsKey(Attribute.align.key)) {
return defaultStyles!.align!.horizontalSpacing; return defaultStyles!.align!.horizontalSpacing;
} }
return const HorizontalSpacing(0, 0); return HorizontalSpacing.zero;
} }
VerticalSpacing _getVerticalSpacingForBlock( VerticalSpacing _getVerticalSpacingForBlock(
@ -1162,7 +1162,7 @@ class QuillRawEditorState extends EditorState
} else if (attrs.containsKey(Attribute.align.key)) { } else if (attrs.containsKey(Attribute.align.key)) {
return defaultStyles!.align!.verticalSpacing; return defaultStyles!.align!.verticalSpacing;
} }
return const VerticalSpacing(0, 0); return VerticalSpacing.zero;
} }
void _didChangeTextEditingValueListener() { void _didChangeTextEditingValueListener() {

@ -271,7 +271,7 @@ class DefaultStyles {
), ),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(16, 0), const VerticalSpacing(16, 0),
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null), null),
h2: DefaultTextBlockStyle( h2: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith( defaultTextStyle.style.copyWith(
@ -284,7 +284,7 @@ class DefaultStyles {
), ),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(8, 0), const VerticalSpacing(8, 0),
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null), null),
h3: DefaultTextBlockStyle( h3: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith( defaultTextStyle.style.copyWith(
@ -297,7 +297,7 @@ class DefaultStyles {
), ),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(8, 0), const VerticalSpacing(8, 0),
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
h4: DefaultTextBlockStyle( h4: DefaultTextBlockStyle(
@ -311,7 +311,7 @@ class DefaultStyles {
), ),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(6, 0), const VerticalSpacing(6, 0),
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
h5: DefaultTextBlockStyle( h5: DefaultTextBlockStyle(
@ -325,7 +325,7 @@ class DefaultStyles {
), ),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(6, 0), const VerticalSpacing(6, 0),
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
h6: DefaultTextBlockStyle( h6: DefaultTextBlockStyle(
@ -339,42 +339,42 @@ class DefaultStyles {
), ),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(4, 0), const VerticalSpacing(4, 0),
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
lineHeightNormal: DefaultTextBlockStyle( lineHeightNormal: DefaultTextBlockStyle(
baseStyle.copyWith(height: 1.15), baseStyle.copyWith(height: 1.15),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
lineHeightTight: DefaultTextBlockStyle( lineHeightTight: DefaultTextBlockStyle(
baseStyle.copyWith(height: 1.30), baseStyle.copyWith(height: 1.30),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
lineHeightOneAndHalf: DefaultTextBlockStyle( lineHeightOneAndHalf: DefaultTextBlockStyle(
baseStyle.copyWith(height: 1.55), baseStyle.copyWith(height: 1.55),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
lineHeightDouble: DefaultTextBlockStyle( lineHeightDouble: DefaultTextBlockStyle(
baseStyle.copyWith(height: 2), baseStyle.copyWith(height: 2),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
paragraph: DefaultTextBlockStyle( paragraph: DefaultTextBlockStyle(
baseStyle, baseStyle,
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
bold: const TextStyle(fontWeight: FontWeight.bold), bold: const TextStyle(fontWeight: FontWeight.bold),
@ -422,8 +422,8 @@ class DefaultStyles {
color: Colors.grey.withOpacity(0.6), color: Colors.grey.withOpacity(0.6),
), ),
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null), null),
lists: DefaultListBlockStyle( lists: DefaultListBlockStyle(
baseStyle, baseStyle,
@ -453,7 +453,7 @@ class DefaultStyles {
), ),
baseHorizontalSpacing, baseHorizontalSpacing,
baseVerticalSpacing, baseVerticalSpacing,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
BoxDecoration( BoxDecoration(
color: Colors.grey.shade50, color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(2), borderRadius: BorderRadius.circular(2),
@ -468,15 +468,15 @@ class DefaultStyles {
align: DefaultTextBlockStyle( align: DefaultTextBlockStyle(
baseStyle, baseStyle,
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
leading: DefaultTextBlockStyle( leading: DefaultTextBlockStyle(
baseStyle, baseStyle,
baseHorizontalSpacing, baseHorizontalSpacing,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
const VerticalSpacing(0, 0), VerticalSpacing.zero,
null, null,
), ),
sizeSmall: const TextStyle(fontSize: 10), sizeSmall: const TextStyle(fontSize: 10),

Loading…
Cancel
Save