0

enter image description here

I am trying to implement this custom slider on my flutter app. I have searched most of the open source libraries but I cannot seem to get the one that suits my need.

The closet I got to is Cupertino Slider but I couldn't customize it to fit my need. Any ideas?

2 Answers 2

1

this is what you are looking for, slider_button:

SliderButton(
      action: () {
        ///Do something here OnSlide
      },

      ///Put label over here
      label: Text(
        "Slide to cancel !",
        style: TextStyle(
            color: Color(0xff4a4a4a),
            fontWeight: FontWeight.w500,
            fontSize: 17),
      ),
      icon: Center(
          child: Icon(
        Icons.power_settings_new,
        color: Colors.white,
        size: 40.0,
        semanticLabel: 'Text to announce in accessibility modes',
      )),

      ///Change All the color and size from here.
      width: 230,
      radius: 10,
      buttonColor: Color(0xffd60000),
      backgroundColor: Color(0xff534bae),
      highlightedColor: Colors.white,
      baseColor: Colors.red,
    );
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
class View extends StatefulWidget {
  const View({Key? key}) : super(key: key);

  @override
  _ViewState createState() => _ViewState();
}

class _ViewState extends State<View> {
  int segmentedControlGroupValue = 0;
  final Map<int, Widget> myTabs = const <int, Widget>{
    0: Icon(Icons.arrow_forward, color: Colors.white,),
    1: Text("Start Shopping", style: TextStyle(color: Colors.orange),)
  };

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: CupertinoSlidingSegmentedControl(
          backgroundColor: Colors.orange.withOpacity(0.2),
            groupValue: segmentedControlGroupValue,
            thumbColor: CupertinoColors.activeOrange,
            children: myTabs,
            onValueChanged: (newValue) {
              setState(() {
                segmentedControlGroupValue = newValue as int;
              });
            }),
      ),
    );
  }
}


enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.