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

pull/116/head
Till Friebe 4 years ago
commit 27c115d54a
  1. 2
      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/quill_delta.dart
  6. 1
      lib/widgets/controller.dart
  7. 2
      lib/widgets/default_styles.dart
  8. 13
      lib/widgets/editor.dart
  9. 3
      lib/widgets/raw_editor.dart
  10. 12
      lib/widgets/responsive_widget.dart
  11. 8
      lib/widgets/text_block.dart
  12. 14
      lib/widgets/text_line.dart
  13. 6
      lib/widgets/text_selection.dart
  14. 131
      lib/widgets/toolbar.dart

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

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

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

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

@ -520,7 +520,7 @@ class Delta {
if (op.isInsert) {
inverted.delete(op.length!);
} else if (op.isRetain && op.isPlain) {
inverted.retain(op.length!, null);
inverted.retain(op.length!);
baseIndex += op.length!;
} else if (op.isDelete || (op.isRetain && op.isNotPlain)) {
final length = op.length!;

@ -33,7 +33,6 @@ class QuillController extends ChangeNotifier {
TextEditingValue get plainTextEditingValue => TextEditingValue(
text: document.toPlainText(),
selection: selection,
composing: TextRange.empty,
);
Style getSelectionStyle() {

@ -6,9 +6,9 @@ class QuillStyles extends InheritedWidget {
final DefaultStyles data;
QuillStyles({
Key? key,
required this.data,
required Widget child,
Key? key,
}) : super(key: key, child: child);
@override

@ -176,14 +176,14 @@ class QuillEditor extends StatefulWidget {
required this.scrollable,
required this.padding,
required this.autoFocus,
this.showCursor,
required this.readOnly,
required this.expands,
this.showCursor,
this.placeholder,
this.enableInteractiveSelection = true,
this.minHeight,
this.maxHeight,
this.customStyles,
required this.expands,
this.textCapitalization = TextCapitalization.sentences,
this.keyboardAppearance = Brightness.light,
this.scrollPhysics,
@ -200,7 +200,6 @@ class QuillEditor extends StatefulWidget {
focusNode: FocusNode(),
autoFocus: true,
readOnly: readOnly,
enableInteractiveSelection: true,
expands: false,
padding: EdgeInsets.zero);
}
@ -726,8 +725,7 @@ class RenderEditor extends RenderEditableContainerBox
);
if (position.offset - word.start <= 1) {
_handleSelectionChange(
TextSelection.collapsed(
offset: word.start, affinity: TextAffinity.downstream),
TextSelection.collapsed(offset: word.start),
cause,
);
} 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 viewportHeight, double scrollOffset, double offsetInViewport) {
List<TextSelectionPoint> endpoints = getEndpointsForSelection(selection);

@ -382,8 +382,6 @@ class RawEditorState extends EditorState
TextInputConfiguration(
inputType: TextInputType.multiline,
readOnly: widget.readOnly,
obscureText: false,
autocorrect: true,
inputAction: TextInputAction.newline,
keyboardAppearance: widget.keyboardAppearance,
textCapitalization: widget.textCapitalization,
@ -702,6 +700,7 @@ class RawEditorState extends EditorState
_keyboardVisible = true;
} else {
_keyboardVisibilityController = KeyboardVisibilityController();
_keyboardVisible = _keyboardVisibilityController!.isVisible;
_keyboardVisibilitySubscription =
_keyboardVisibilityController?.onChange.listen((bool visible) {
_keyboardVisible = visible;

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

@ -253,11 +253,11 @@ class EditableTextBlock extends StatelessWidget {
class RenderEditableTextBlock extends RenderEditableContainerBox
implements RenderEditableBox {
RenderEditableTextBlock({
List<RenderEditableBox>? children,
required Block block,
required TextDirection textDirection,
required EdgeInsetsGeometry padding,
required Decoration decoration,
List<RenderEditableBox>? children,
ImageConfiguration configuration = ImageConfiguration.empty,
EdgeInsets contentPadding = EdgeInsets.zero,
}) : _decoration = decoration,
@ -559,7 +559,6 @@ class _NumberPoint extends StatelessWidget {
final double padding;
const _NumberPoint({
Key? key,
required this.index,
required this.indentLevelCounts,
required this.count,
@ -568,6 +567,7 @@ class _NumberPoint extends StatelessWidget {
required this.attrs,
this.withDot = true,
this.padding = 0.0,
Key? key,
}) : super(key: key);
@override
@ -624,7 +624,7 @@ class _NumberPoint extends StatelessWidget {
n = (n / 26).floor();
}
return result.toString().split('').reversed.join('');
return result.toString().split('').reversed.join();
}
String _intToRoman(int input) {
@ -657,9 +657,9 @@ class _BulletPoint extends StatelessWidget {
final double width;
const _BulletPoint({
Key? key,
required this.style,
required this.width,
Key? key,
}) : super(key: key);
@override

@ -27,13 +27,13 @@ class TextLine extends StatelessWidget {
final EmbedBuilder embedBuilder;
final DefaultStyles styles;
const TextLine(
{Key? key,
required this.line,
this.textDirection,
required this.embedBuilder,
required this.styles})
: super(key: key);
const TextLine({
required this.line,
required this.embedBuilder,
required this.styles,
this.textDirection,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {

@ -246,7 +246,6 @@ class EditorTextSelectionOverlay {
class _TextSelectionHandleOverlay extends StatefulWidget {
const _TextSelectionHandleOverlay({
Key? key,
required this.selection,
required this.position,
required this.startHandleLayerLink,
@ -256,6 +255,7 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
required this.onSelectionHandleTapped,
required this.selectionControls,
this.dragStartBehavior = DragStartBehavior.start,
Key? key,
}) : super(key: key);
final TextSelection selection;
@ -469,7 +469,7 @@ class _TextSelectionHandleOverlayState
class EditorTextSelectionGestureDetector extends StatefulWidget {
const EditorTextSelectionGestureDetector({
Key? key,
required this.child,
this.onTapDown,
this.onForcePressStart,
this.onForcePressEnd,
@ -483,7 +483,7 @@ class EditorTextSelectionGestureDetector extends StatefulWidget {
this.onDragSelectionUpdate,
this.onDragSelectionEnd,
this.behavior,
required this.child,
Key? key,
}) : super(key: key);
final GestureTapDownCallback? onTapDown;

@ -25,9 +25,9 @@ class InsertEmbedButton extends StatelessWidget {
final IconData icon;
const InsertEmbedButton({
Key? key,
required this.controller,
required this.icon,
Key? key,
}) : super(key: key);
@override
@ -56,9 +56,9 @@ class LinkStyleButton extends StatefulWidget {
final IconData? icon;
const LinkStyleButton({
Key? key,
required this.controller,
this.icon,
Key? key,
}) : super(key: key);
@override
@ -183,11 +183,11 @@ class ToggleStyleButton extends StatefulWidget {
final ToggleStyleButtonBuilder childBuilder;
ToggleStyleButton({
Key? key,
required this.attribute,
required this.icon,
required this.controller,
this.childBuilder = defaultToggleStyleButtonBuilder,
Key? key,
}) : super(key: key);
@override
@ -267,11 +267,11 @@ class ToggleCheckListButton extends StatefulWidget {
final Attribute attribute;
ToggleCheckListButton({
Key? key,
required this.icon,
required this.controller,
this.childBuilder = defaultToggleStyleButtonBuilder,
required this.attribute,
this.childBuilder = defaultToggleStyleButtonBuilder,
Key? key,
}) : super(key: key);
@override
@ -371,7 +371,7 @@ Widget defaultToggleStyleButtonBuilder(
class SelectHeaderStyleButton extends StatefulWidget {
final QuillController controller;
const SelectHeaderStyleButton({Key? key, required this.controller})
const SelectHeaderStyleButton({required this.controller, Key? key})
: super(key: key);
@override
@ -494,14 +494,14 @@ class ImageButton extends StatefulWidget {
final ImageSource imageSource;
ImageButton(
{Key? key,
required this.icon,
required this.controller,
required this.imageSource,
this.onImagePickCallback,
this.imagePickImpl})
: super(key: key);
ImageButton({
required this.icon,
required this.controller,
required this.imageSource,
this.onImagePickCallback,
this.imagePickImpl,
Key? key,
}) : super(key: key);
@override
_ImageButtonState createState() => _ImageButtonState();
@ -525,7 +525,6 @@ class _ImageButtonState extends State<ImageButton> {
Future<String?> _pickImageWeb() async {
_paths = (await FilePicker.platform.pickFiles(
type: _pickingType,
allowMultiple: false,
allowedExtensions: (_extension?.isNotEmpty ?? false)
? _extension?.replaceAll(' ', '').split(',')
: null,
@ -601,12 +600,12 @@ class ColorButton extends StatefulWidget {
final bool background;
final QuillController controller;
ColorButton(
{Key? key,
required this.icon,
required this.controller,
required this.background})
: super(key: key);
ColorButton({
required this.icon,
required this.controller,
required this.background,
Key? key,
}) : super(key: key);
@override
_ColorButtonState createState() => _ColorButtonState();
@ -739,12 +738,12 @@ class HistoryButton extends StatefulWidget {
final bool undo;
final QuillController controller;
HistoryButton(
{Key? key,
required this.icon,
required this.controller,
required this.undo})
: super(key: key);
HistoryButton({
required this.icon,
required this.controller,
required this.undo,
Key? key,
}) : super(key: key);
@override
_HistoryButtonState createState() => _HistoryButtonState();
@ -811,12 +810,12 @@ class IndentButton extends StatefulWidget {
final QuillController controller;
final bool isIncrease;
IndentButton(
{Key? key,
required this.icon,
required this.controller,
required this.isIncrease})
: super(key: key);
IndentButton({
required this.icon,
required this.controller,
required this.isIncrease,
Key? key,
}) : super(key: key);
@override
_IndentButtonState createState() => _IndentButtonState();
@ -866,7 +865,7 @@ class ClearFormatButton extends StatefulWidget {
final QuillController controller;
ClearFormatButton({Key? key, required this.icon, required this.controller})
ClearFormatButton({required this.icon, required this.controller, Key? key})
: super(key: key);
@override
@ -897,30 +896,31 @@ class _ClearFormatButtonState extends State<ClearFormatButton> {
class QuillToolbar extends StatefulWidget implements PreferredSizeWidget {
final List<Widget> children;
const QuillToolbar({Key? key, required this.children}) : super(key: key);
factory QuillToolbar.basic(
{Key? key,
required QuillController controller,
double toolbarIconSize = 18.0,
bool showBoldButton = true,
bool showItalicButton = true,
bool showUnderLineButton = true,
bool showStrikeThrough = true,
bool showColorButton = true,
bool showBackgroundColorButton = true,
bool showClearFormat = true,
bool showHeaderStyle = true,
bool showListNumbers = true,
bool showListBullets = true,
bool showListCheck = true,
bool showCodeBlock = true,
bool showQuote = true,
bool showIndent = true,
bool showLink = true,
bool showHistory = true,
bool showHorizontalRule = false,
OnImagePickCallback? onImagePickCallback}) {
const QuillToolbar({required this.children, Key? key}) : super(key: key);
factory QuillToolbar.basic({
required QuillController controller,
double toolbarIconSize = 18.0,
bool showBoldButton = true,
bool showItalicButton = true,
bool showUnderLineButton = true,
bool showStrikeThrough = true,
bool showColorButton = true,
bool showBackgroundColorButton = true,
bool showClearFormat = true,
bool showHeaderStyle = true,
bool showListNumbers = true,
bool showListBullets = true,
bool showListCheck = true,
bool showCodeBlock = true,
bool showQuote = true,
bool showIndent = true,
bool showLink = true,
bool showHistory = true,
bool showHorizontalRule = false,
OnImagePickCallback? onImagePickCallback,
Key? key,
}) {
iconSize = toolbarIconSize;
return QuillToolbar(key: key, children: [
Visibility(
@ -1147,13 +1147,13 @@ class QuillIconButton extends StatelessWidget {
final double highlightElevation;
const QuillIconButton({
Key? key,
required this.onPressed,
this.icon,
this.size = 40,
this.fillColor,
this.hoverElevation = 1,
this.highlightElevation = 1,
Key? key,
}) : super(key: key);
@override
@ -1163,7 +1163,6 @@ class QuillIconButton extends StatelessWidget {
child: RawMaterialButton(
visualDensity: VisualDensity.compact,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)),
padding: EdgeInsets.zero,
fillColor: fillColor,
elevation: 0,
hoverElevation: hoverElevation,
@ -1186,15 +1185,15 @@ class QuillDropdownButton<T> extends StatefulWidget {
final ValueChanged<T> onSelected;
const QuillDropdownButton({
Key? key,
this.height = 40,
this.fillColor,
this.hoverElevation = 1,
this.highlightElevation = 1,
required this.child,
required this.initialValue,
required this.items,
required this.onSelected,
this.height = 40,
this.fillColor,
this.hoverElevation = 1,
this.highlightElevation = 1,
Key? key,
}) : super(key: key);
@override
@ -1209,7 +1208,6 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> {
child: RawMaterialButton(
visualDensity: VisualDensity.compact,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)),
padding: EdgeInsets.zero,
fillColor: widget.fillColor,
elevation: 0,
hoverElevation: widget.hoverElevation,
@ -1250,6 +1248,7 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> {
// if (widget.onCanceled != null) widget.onCanceled();
return null;
}
widget.onSelected(newValue);
});
}

Loading…
Cancel
Save