Each ConfigurationField now consists out of three components:
FieldConfigurator<TYPE>
FieldConfigurator<TYPE?>
And a ConfigurationWidget<TYPE?> or a StatefulConfigurationWidget<TYPE?>
The first both are the ones used in the stage to represent a non-nullable value or a nullable value.
The ConfigurationWidget is the actual widget shown to the user to adjust the values. It contains the shared logic of both FieldConfigurators.
This has a little boilerplate where i try to build a IntelliJ plugin for.
Before that you can use this livetemplates to generate the basic structure:
ConfigurationWidget
/// Represents a nullable $TYPE$ parameter for a widget on a [WidgetStage].
class $TYPENAME$FieldConfiguratorNullable extends FieldConfigurator<$TYPE$?> {
$TYPENAME$FieldConfiguratorNullable({
required super.value,
required super.name,
});
@override
Widget build(BuildContext context) {
return $TYPENAME$FieldConfigurationWidget(
value: value,
updateValue: updateValue,
);
}
}
/// Represents a $TYPE$ parameter for a widget on a [WidgetStage].
class $TYPENAME$FieldConfigurator extends FieldConfigurator<$TYPE$> {
$TYPENAME$FieldConfigurator({
required super.value,
required super.name,
});
@override
Widget build(BuildContext context) {
return $TYPENAME$FieldConfigurationWidget(
value: value,
updateValue: (value) {
updateValue(value ?? false);
},
);
}
}
class $TYPENAME$FieldConfigurationWidget extends ConfigurationWidget<$TYPE$?> {
const $TYPENAME$FieldConfigurationWidget({
required super.value,
required super.updateValue,
});
@override
Widget build(BuildContext context) {
// return youre field configurator here.
// Use the value to set the initial value and updateValue to update the value.
}
}
StatefulConfigurationWidget
/// Represents a nullable $TYPE$ parameter for a widget on a [WidgetStage].
class $CNAME$FieldConfiguratorNullable extends FieldConfigurator<$TYPE$?> {
$CNAME$FieldConfiguratorNullable({
required super.value,
required super.name,
});
@override
Widget build(BuildContext context) {
return $CNAME$FieldConfigurationWidget(
value: value,
updateValue: updateValue,
);
}
}
/// Represents a $TYPE$ parameter for a widget on a [WidgetStage].
class $CNAME$FieldConfigurator extends FieldConfigurator<$TYPE$> {
$CNAME$FieldConfigurator({
required super.value,
required super.name,
});
@override
Widget build(BuildContext context) {
return $CNAME$FieldConfigurationWidget(
value: value,
updateValue: (value) {
updateValue(value ?? '');
},
);
}
}
class $CNAME$FieldConfigurationWidget extends StatefulConfigurationWidget<$TYPE$?> {
const $CNAME$FieldConfigurationWidget({
super.key,
required super.value,
required super.updateValue,
});
@override
State<$CNAME$FieldConfigurationWidget> createState() => _$CNAME$FieldConfigurationWidgetState();
}
class _$CNAME$FieldConfigurationWidgetState extends State<$CNAME$FieldConfigurationWidget> {
// for example
late final TextEditingController _controller = TextEditingController(text: widget.value);
@override
Widget build(BuildContext context) {
return TextField(
decoration: const InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8),
),
),
),
controller: _controller,
onChanged: widget.updateValue,
);
}
}
Each ConfigurationField now consists out of three components:
FieldConfigurator<TYPE>
FieldConfigurator<TYPE?>
And aConfigurationWidget<TYPE?>
or aStatefulConfigurationWidget<TYPE?>
The first both are the ones used in the stage to represent a non-nullable value or a nullable value. The
ConfigurationWidget
is the actual widget shown to the user to adjust the values. It contains the shared logic of bothFieldConfigurator
s.This has a little boilerplate where i try to build a IntelliJ plugin for. Before that you can use this livetemplates to generate the basic structure:
ConfigurationWidget
StatefulConfigurationWidget