@@ -48,17 +48,20 @@ class SearchButton extends StatelessWidget {
48
48
Future <void > _onPressedHandler (BuildContext context) async {
49
49
await showDialog <String >(
50
50
context: context,
51
- builder: (_) => _SearchDialog (dialogTheme: dialogTheme, text: '' ),
51
+ builder: (_) => _SearchDialog (
52
+ controller: controller, dialogTheme: dialogTheme, text: '' ),
52
53
).then (_searchSubmitted);
53
54
}
54
55
55
56
void _searchSubmitted (String ? value) {}
56
57
}
57
58
58
59
class _SearchDialog extends StatefulWidget {
59
- const _SearchDialog ({this .dialogTheme, this .text, Key ? key})
60
+ const _SearchDialog (
61
+ {required this .controller, this .dialogTheme, this .text, Key ? key})
60
62
: super (key: key);
61
63
64
+ final QuillController controller;
62
65
final QuillDialogTheme ? dialogTheme;
63
66
final String ? text;
64
67
@@ -90,11 +93,15 @@ class _SearchDialogState extends State<_SearchDialog> {
90
93
labelStyle: widget.dialogTheme? .labelTextStyle,
91
94
floatingLabelStyle: widget.dialogTheme? .labelTextStyle),
92
95
autofocus: true ,
96
+ onChanged: _textChanged,
93
97
controller: _controller,
94
98
),
95
99
actions: [
96
100
TextButton (
97
- onPressed: () {},
101
+ onPressed: () {
102
+ final offsets = widget.controller.document.search (_text);
103
+ debugPrint (offsets.toString ());
104
+ },
98
105
child: Text (
99
106
'Ok' .i18n,
100
107
style: widget.dialogTheme? .labelTextStyle,
@@ -103,4 +110,10 @@ class _SearchDialogState extends State<_SearchDialog> {
103
110
],
104
111
);
105
112
}
113
+
114
+ void _textChanged (String value) {
115
+ setState (() {
116
+ _text = value;
117
+ });
118
+ }
106
119
}
0 commit comments