paperButton
PaperButton
paperButton(
Create a Paper Button with full type safety.
final btn = paperButton(
props: (mode: 'contained', disabled: false, loading: null,
buttonColor: '#6200EE', textColor: null, style: null,
contentStyle: null, labelStyle: null),
onPress: () => print('pressed'),
label: 'Click Me',
);
Implementation
PaperButton paperButton({
PaperButtonProps? props,
void Function()? onPress,
String? label,
}) {
final p = <String, dynamic>{};
if (props != null) {
if (props.mode != null) p['mode'] = props.mode;
if (props.disabled != null) p['disabled'] = props.disabled;
if (props.loading != null) p['loading'] = props.loading;
if (props.buttonColor != null) p['buttonColor'] = props.buttonColor;
if (props.textColor != null) p['textColor'] = props.textColor;
if (props.style != null) p['style'] = props.style;
if (props.contentStyle != null) p['contentStyle'] = props.contentStyle;
if (props.labelStyle != null) p['labelStyle'] = props.labelStyle;
}
if (onPress != null) p['onPress'] = onPress;
return PaperButton._create(
npmComponent(
'react-native-paper',
'Button',
props: p.isEmpty ? null : p,
child: label?.toJS,
),
);
}