I want to make a sliding switch like this
and I also made it through CupertinoSlidingSegmentedControl()
but it is not meeting my requirements. I would like a similar slider switch.
I've made like this.
Neumorphic(
style: NeumorphicStyle(
depth: NeumorphicTheme.embossDepth(context),
boxShape: const NeumorphicBoxShape.stadium(),
intensity: 1),
child: ToggleSwitch(
minWidth: 120.0,
minHeight: 70,
cornerRadius: 50.0,
activeBgColors: const [
[Colors.cyan],
[Colors.cyan]
],
inactiveBgColor: Colors.grey[200],
inactiveFgColor: Colors.grey,
totalSwitches: 2,
labels: ['Agency', 'Freelancer'],
radiusStyle: true,
onToggle: (index) {},
),
),
you can use this package toggle_switch: ^1.4.0 and create it like this
SizedBox(
height: 40,
child: ToggleSwitch(
minWidth: 90.0,
cornerRadius: 20.0,
activeBgColors: [const [Colors.cyan],const [Colors.cyan]],
activeFgColor: Colors.white,
inactiveBgColor: Colors.grey,
inactiveFgColor: Colors.white,
initialLabelIndex: 1,
totalSwitches: 2,
labels: ['Agency', 'Freelancer'],
radiusStyle: true,
onToggle: (index) {
print('switched to: $index');
},
),
),