From 7cfa8afb8f7ce23bc1e55b8d14e5828e13507041 Mon Sep 17 00:00:00 2001 From: Milind Goel Date: Thu, 19 Oct 2023 15:46:28 +0530 Subject: [PATCH] added a textSelectionColor property to fix [Feature Request] More UI customisation options #1431 --- lib/src/widgets/editor.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/src/widgets/editor.dart b/lib/src/widgets/editor.dart index 11fd530d..751a3977 100644 --- a/lib/src/widgets/editor.dart +++ b/lib/src/widgets/editor.dart @@ -1,5 +1,4 @@ import 'dart:math' as math; - // ignore: unnecessary_import import 'dart:typed_data'; @@ -193,6 +192,7 @@ class QuillEditor extends StatefulWidget { this.contentInsertionConfiguration, this.contextMenuBuilder, this.editorKey, + this.textSelectionColor, Key? key, }) : super(key: key); @@ -455,6 +455,11 @@ class QuillEditor extends StatefulWidget { /// editorKey.currentState?.renderEditor.getLocalRectForCaret final GlobalKey? editorKey; + /// Allows for providing a custom text selection color. + /// + /// Defaults to Material selectionTheme or primary color. + final Color? textSelectionColor; + @override QuillEditorState createState() => QuillEditorState(); } @@ -493,7 +498,8 @@ class QuillEditorState extends State paintCursorAboveText = true; cursorOpacityAnimates = true; cursorColor ??= selectionTheme.cursorColor ?? cupertinoTheme.primaryColor; - selectionColor = selectionTheme.selectionColor ?? + selectionColor = widget.textSelectionColor ?? + selectionTheme.selectionColor ?? cupertinoTheme.primaryColor.withOpacity(0.40); cursorRadius ??= const Radius.circular(2); cursorOffset = Offset( @@ -503,7 +509,8 @@ class QuillEditorState extends State paintCursorAboveText = false; cursorOpacityAnimates = false; cursorColor ??= selectionTheme.cursorColor ?? theme.colorScheme.primary; - selectionColor = selectionTheme.selectionColor ?? + selectionColor = widget.textSelectionColor ?? + selectionTheme.selectionColor ?? theme.colorScheme.primary.withOpacity(0.40); }