|
|
@ -5,6 +5,7 @@ class QuillDropdownButton<T> extends StatefulWidget { |
|
|
|
const QuillDropdownButton({ |
|
|
|
const QuillDropdownButton({ |
|
|
|
required this.initialValue, |
|
|
|
required this.initialValue, |
|
|
|
required this.items, |
|
|
|
required this.items, |
|
|
|
|
|
|
|
required this.rawitemsmap, |
|
|
|
required this.onSelected, |
|
|
|
required this.onSelected, |
|
|
|
this.height = 40, |
|
|
|
this.height = 40, |
|
|
|
this.fillColor, |
|
|
|
this.fillColor, |
|
|
@ -20,6 +21,7 @@ class QuillDropdownButton<T> extends StatefulWidget { |
|
|
|
final double highlightElevation; |
|
|
|
final double highlightElevation; |
|
|
|
final T initialValue; |
|
|
|
final T initialValue; |
|
|
|
final List<PopupMenuEntry<T>> items; |
|
|
|
final List<PopupMenuEntry<T>> items; |
|
|
|
|
|
|
|
final Map<String,int> rawitemsmap; |
|
|
|
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.rawitemsmap.keys.elementAt(widget.initialValue as int); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
@ -87,25 +89,23 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
setState(() { |
|
|
|
setState(() { |
|
|
|
_currentValue = newValue as int; |
|
|
|
_currentValue = widget.rawitemsmap.entries.firstWhere((element) => element.value==newValue, orElse: () => widget.rawitemsmap.entries.first).key; |
|
|
|
widget.onSelected(newValue); |
|
|
|
widget.onSelected(newValue); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget _buildContent(BuildContext context) { |
|
|
|
Widget _buildContent(BuildContext context) { |
|
|
|
return ConstrainedBox( |
|
|
|
return Padding( |
|
|
|
constraints: const BoxConstraints.tightFor(width: 60), |
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10), |
|
|
|
child: Padding( |
|
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8), |
|
|
|
|
|
|
|
child: Row( |
|
|
|
child: Row( |
|
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Text(_currentValue.toString()), |
|
|
|
Text(_currentValue.toString()), |
|
|
|
Expanded(child: Container()), |
|
|
|
SizedBox(width:6), |
|
|
|
const Icon(Icons.arrow_drop_down, size: 15) |
|
|
|
const Icon(Icons.arrow_drop_down, size: 17) |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|