Flutter 中的滑块开关
我想制作一个像这样的滑动开关
,我也通过 CupertinoSlidingSegmentedControl()
做到了,但它不符合我的要求。我想要一个类似的滑块开关。
我是这样弄的
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) {},
),
),
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) {},
),
),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以使用这个包toggle_switch: ^1.4.0并像这样创建它
you can use this package toggle_switch: ^1.4.0 and create it like this