Code Monkey home page Code Monkey logo

dh_slider's Introduction

dh_sliderdh_slider

A handy slider that supports color and image settings for thumb and track.

How to use

  • Import dh_slider
import 'package:dh_slider/dh_slider.dart';
  • Use color to set slider
DHSlider(
    thumbBorderSide: BorderSide.none,
    thumbColor: Colors.redAccent,
    trackHeight: 3,
    margin: EdgeInsets.only(left: 10, right: 10, top: 20),
    value: slider,
    onChanged: (double value){
      this.setState(() {
        slider = value;
      });
    })
  • Use image to set slider
FutureBuilder(
  future: sliderFuture,
  builder: (BuildContext context, AsyncSnapshot<ui.Image> snapshot) {
    return DHSlider(
      value: slider,
      trackImage: snapshot.data,
      trackHeight: 13,
      activeTrackColor: Colors.transparent,
      inactiveTrackColor: Colors.transparent,
      disabledActiveTrackColor: Colors.transparent,
      disabledInactiveTrackColor: Colors.transparent,
      thumbColor: Colors.white,
      disabledThumbColor: Colors.white,
      enabledThumbRadius: 12,
      margin: EdgeInsets.only(left: 10, right: 10, top: 30),
      thumbBorderSide: BorderSide(
        width: 0.6,
        color: Colors.red,
      ),
      onChanged: (value) {
        this.setState(() => slider = value);
      },
      min: 0,
      max: 1,
    );
  }

To use image settings for track and thumb, use DHSlider.image.

  • Add mark for slider
DHSliderTrackShape(
  alignThumbCenter: false,
  marks: ['0', '35', '70', '100'],
  activeMarkStyle: TextStyle(color: Colors.white, fontSize: 14),
  inactiveMarkStyle: TextStyle(color: Color(0xFF7F7F7F), fontSize: 12),
  disabledActiveMarkStyle: TextStyle(color: Colors.red, fontSize: 14),
  disabledInactiveMarkStyle: TextStyle(color: Colors.brown, fontSize: 12),
)

Customize trackShape parameters, set marks and markStyle.

  • Add text for thumb
DHThumbShape(
    borderSide: BorderSide(width: 4, color: Color(0xFFFAAA00)),
    label: "value",
    enabledThumbRadius: 21,
    labelStyle: TextStyle(color: Colors.cyan, fontSize: 14))

Customize thumbShape parameters, set label and labelStyle.

dh_slider's People

Contributors

thesnowfish avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

dh_slider's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.