Skip to content

Commit

Permalink
Update PlatformCheckbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Lance Johnstone authored and Lance Johnstone committed Jul 2, 2023
1 parent cc7d0f2 commit 63eccd8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
3 changes: 3 additions & 0 deletions example/lib/platform_page.dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ class PlatformPage extends StatelessWidget {
onChanged: (newValue) {
setValue(newValue!);
},
),
),
),
// ! PlatformRadio
PlatformWidgetExample(
title: 'PlatformRadio',
Expand Down
40 changes: 20 additions & 20 deletions lib/src/platform_checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ abstract class _BaseData {
_BaseData({
this.widgetKey,
this.value,
this.tristate = false,
this.tristate,
this.onChanged,
this.activeColor,
this.checkColor,
this.focusColor,
this.focusNode,
this.autofocus = false,
this.autofocus,
this.shape,
this.side,
});
final Key? widgetKey;
final bool? value;
final bool tristate;
final bool? tristate;
final ValueChanged<bool?>? onChanged;
final Color? activeColor;
final Color? checkColor;
final Color? focusColor;
final FocusNode? focusNode;
final bool autofocus;
final bool? autofocus;
final OutlinedBorder? shape;
final BorderSide? side;
}
Expand All @@ -44,13 +44,13 @@ class MaterialCheckboxData extends _BaseData {
// Common
super.widgetKey,
super.value,
super.tristate = false,
super.tristate,
super.onChanged,
super.activeColor,
super.checkColor,
super.focusColor,
super.focusNode,
super.autofocus = false,
super.autofocus,
super.shape,
super.side,
//Material
Expand Down Expand Up @@ -79,13 +79,13 @@ class CupertinoCheckboxData extends _BaseData {
//Common
super.widgetKey,
super.value,
super.tristate = false,
super.tristate,
super.onChanged,
super.activeColor,
super.checkColor,
super.focusColor,
super.focusNode,
super.autofocus = false,
super.autofocus,
super.shape,
super.side,

Expand Down Expand Up @@ -115,10 +115,10 @@ class PlatformCheckbox extends PlatformWidgetBase<CupertinoCheckbox, Checkbox> {
final PlatformBuilder<CupertinoCheckboxData>? cupertino;

PlatformCheckbox({
required this.onChanged,
//Common
super.key,
this.widgetKey,
required this.onChanged,
this.value,
this.tristate = false,
this.activeColor,
Expand All @@ -140,6 +140,15 @@ class PlatformCheckbox extends PlatformWidgetBase<CupertinoCheckbox, Checkbox> {
final tristate = data?.tristate ?? this.tristate;
assert(tristate || value != null);
return Checkbox(
//Material
mouseCursor: data?.mouseCursor,
fillColor: data?.fillColor,
hoverColor: data?.hoverColor,
overlayColor: data?.overlayColor,
splashRadius: data?.splashRadius,
materialTapTargetSize: data?.materialTapTargetSize,
visualDensity: data?.visualDensity,
isError: data?.isError ?? false,
//Common
key: data?.widgetKey ?? widgetKey,
value: value,
Expand All @@ -152,15 +161,6 @@ class PlatformCheckbox extends PlatformWidgetBase<CupertinoCheckbox, Checkbox> {
autofocus: data?.autofocus ?? autofocus,
shape: data?.shape ?? shape,
side: data?.side ?? side,
//Material
mouseCursor: data?.mouseCursor,
fillColor: data?.fillColor,
hoverColor: data?.hoverColor,
overlayColor: data?.overlayColor,
splashRadius: data?.splashRadius,
materialTapTargetSize: data?.materialTapTargetSize,
visualDensity: data?.visualDensity,
isError: data?.isError ?? false,
);
}

Expand All @@ -171,6 +171,8 @@ class PlatformCheckbox extends PlatformWidgetBase<CupertinoCheckbox, Checkbox> {
final tristate = data?.tristate ?? this.tristate;
assert(tristate || value != null);
return CupertinoCheckbox(
//Cupertino
inactiveColor: data?.inactiveColor,
//Common
key: data?.widgetKey ?? widgetKey,
value: value,
Expand All @@ -183,8 +185,6 @@ class PlatformCheckbox extends PlatformWidgetBase<CupertinoCheckbox, Checkbox> {
autofocus: data?.autofocus ?? autofocus,
shape: data?.shape ?? shape,
side: data?.side ?? side,
//Cupertino
inactiveColor: data?.inactiveColor,
);
}
}

0 comments on commit 63eccd8

Please sign in to comment.