Update quill_dropdown_button.dart

pull/794/head
mark8044 3 years ago committed by GitHub
parent 53e97c81d3
commit f91ad4d4b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      lib/src/widgets/toolbar/quill_dropdown_button.dart

@ -4,6 +4,7 @@ import '../../models/themes/quill_icon_theme.dart';
class QuillDropdownButton<T> extends StatefulWidget { class QuillDropdownButton<T> extends StatefulWidget {
const QuillDropdownButton({ const QuillDropdownButton({
required this.initialValue, required this.initialValue,
required this.initialValueTitle,
required this.items, required this.items,
required this.onSelected, required this.onSelected,
this.height = 40, this.height = 40,
@ -19,6 +20,7 @@ class QuillDropdownButton<T> extends StatefulWidget {
final double hoverElevation; final double hoverElevation;
final double highlightElevation; final double highlightElevation;
final T initialValue; final T initialValue;
final String initialValueTitle;
final List<PopupMenuEntry<T>> items; final List<PopupMenuEntry<T>> items;
final ValueChanged<T> onSelected; final ValueChanged<T> onSelected;
final QuillIconTheme? iconTheme; final QuillIconTheme? iconTheme;
@ -29,12 +31,12 @@ class QuillDropdownButton<T> extends StatefulWidget {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> { class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> {
int _currentValue = 0; String _currentValue = '';
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_currentValue = widget.initialValue as int; _currentValue = widget.initialValueTitle;
} }
@override @override
@ -87,7 +89,7 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> {
return null; return null;
} }
setState(() { setState(() {
_currentValue = newValue as int; _currentValue = ((widget.items[1].key) as ValueKey<String>).value;
widget.onSelected(newValue); widget.onSelected(newValue);
}); });
}); });

Loading…
Cancel
Save