How to merge Style from parent spec.
- Dominant language
- Dart
- Stars
- 800
- Forks
- 49
- Avg merge
- 3h 39m
- Merged PRs (30d)
- 22
Description
### Use case
We have Spec
```dart
final class ButtonSpec extends Spec
with Diagnosticable, _$ButtonSpecMethods {
@override
final StyleSpec? container;
@override
final StyleSpec? icon;
@override
final StyleSpec? label;
const ButtonSpec({
this.container,
this.icon,
this.label,
});
}
```
The button widget,with `Widget child` and `Widget icon`
```
class UIButton extends StatelessWidget {
const UIButton({
super.key,
required this.onPressed,
this.child,
this.icon,
this.style,
this.variant = ButtonVariant.primary,
this.size = ButtonVariantSize.sm,
});
final VoidCallback onPressed;
final Widget? child;
final Widget? icon;
final ButtonStyler? style;
final ButtonVariant variant;
final ButtonVariantSize size;
@override
Widget build(BuildContext context) {
final child = this.child;
final icon = this.icon;
return StyleBuilder(
style: _getButtonStyle(
style,
variant: variant,
size: size,
),
builder: (context, spec) => FlexBox(
styleSpec: spec.container,
children: [
if (spec.label != null && child != null)
StyleSpecProvider(
spec: spec.label!,
child: child,
),
if (spec.icon != null && icon != null)
StyleSpecProvider(
spec: spec.icon!,
child: icon,
),
],
),
);
}
}
```
### Proposal
What we want to do is:
```
UIButton(
onPressed: () {},
size: size,
variant: variant,
child: StyledText(
title,
styleSpec: StyleSpecProvider.of(context),
style: TextStyler().fontSize(38) // <= merge context style,and make font bigger only
),
);
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how StyleSpecProvider.of(context), StyledText, and TextStyler currently obtain and apply styles. Define how a child style should merge with the parent context style, including the font-size override shown in the proposal; done means the intended UIButton and StyledText usage works consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- design, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100