Implementation
Widget settingsWidget(
BuildContext context, {
String title = '',
String name = '',
String tooltip = '',
dynamic suffix = 0,
String placeholder = '',
bool checkbox = false,
}) {
if (name.isEmpty) {
name = title;
}
if (_settings[name] == null) {
_settings[name] = TextEditingController(text: '');
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title),
Padding(
padding: const EdgeInsets.only(bottom: 8.0, top: 4.0),
child: Tooltip(
message: tooltip,
child: checkbox
? Checkbox(
checked: _settings[name]!.text == 'true',
onChanged: (value) {
if (value != null) {
_settings[name]!.text = value ? 'true' : 'false';
setState(() {
_settings = _settings;
});
}
})
: TextBox(
controller: _settings[name],
placeholder: placeholder,
suffix: suffix != 0 ? suffix : Container(),
),
),
),
],
);
}