I need to know whether Flutter will render the iOS Cupertino style on iOS and Material on Android with a single codebase. I want to know this before starting to develop my app w
Below simple implementation:
class AdaptiveSwitch extends StatelessWidget {
const AdaptiveSwitch({Key key,
@required this.value,
@required this.onChanged,
this.activeColor,
this.dragStartBehavior = DragStartBehavior.start})
: assert(dragStartBehavior != null),
super(key: key);
final bool value;
final ValueChanged onChanged;
final Color activeColor;
final DragStartBehavior dragStartBehavior;
@override
Widget build(BuildContext context) {
return Theme.of(context).targetPlatform = TargetPlatform.iOS
? CupertinoSwitch(
value: value,
activeColor: activeColor,
onChanged: onChanged,
dragStartBehavior: dragStartBehavior,
)
: Switch(
value: value,
activeColor: activeColor,
onChanged: onChanged,
dragStartBehavior: dragStartBehavior,
);
}
}