Nikolas Rimikis
2 years ago
4 changed files with 33 additions and 40 deletions
@ -1,22 +1,23 @@ |
|||||||
part of '../../settings.dart'; |
part of '../../settings.dart'; |
||||||
|
|
||||||
class OptionBuilder<T> extends StatelessWidget { |
typedef OptionBuilderFunction<T> = Widget Function(BuildContext context, T snapshot); |
||||||
const OptionBuilder({ |
|
||||||
|
class OptionBuilder<T> extends StreamBuilderBase<T, T> { |
||||||
|
OptionBuilder({ |
||||||
required this.option, |
required this.option, |
||||||
required this.builder, |
required this.builder, |
||||||
super.key, |
super.key, |
||||||
}); |
}) : super(stream: option.stream); |
||||||
|
|
||||||
final Option<T> option; |
final Option<T> option; |
||||||
final Widget Function(BuildContext context, T? data) builder; |
final OptionBuilderFunction<T> builder; |
||||||
|
|
||||||
|
@override |
||||||
|
T afterData(final T current, final T data) => data; |
||||||
|
|
||||||
|
@override |
||||||
|
T initial() => option.defaultValue; |
||||||
|
|
||||||
@override |
@override |
||||||
Widget build(final BuildContext context) => StreamBuilder<T?>( |
Widget build(final BuildContext context, final T currentSummary) => builder(context, currentSummary); |
||||||
stream: option.stream, |
|
||||||
initialData: option.defaultValue, |
|
||||||
builder: (final context, final valueSnapshot) => builder( |
|
||||||
context, |
|
||||||
valueSnapshot.data, |
|
||||||
), |
|
||||||
); |
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue