How to create a Slider in Flutter?

This Article is posted by seven.srikanth at 5/23/2019 6:57:26 PM



<p _value="newValue;">Here is the example of how to create a Slider in flutter. To run this example, copy paste this code insider your main.dart file and run. color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;](color: #569cd6;](import color: #ce9178;]('package:flutter/material.dart'; color: #569cd6;](void main() => runApp(MyApp()); color: #569cd6;](class MyApp color: #569cd6;](extends StatelessWidget { color: #569cd6;](@override Widget build(BuildContext context) { color: #569cd6;](return MaterialApp( title: color: #ce9178;]('Flutter Slider Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: color: #ce9178;]('Flutter Slider Demo Home Page'), ); }} color: #569cd6;](class MyHomePage color: #569cd6;](extends StatefulWidget { MyHomePage({Key key, color: #569cd6;](this.title}) : color: #569cd6;](super(key: key); color: #569cd6;](final String title; color: #569cd6;](@override _MyHomePageState createState() => _MyHomePageState();} color: #569cd6;](class _MyHomePageState color: #569cd6;](extends State { color: #569cd6;](double _value = color: #b5cea8;](0.5; color: #569cd6;](@override Widget build(BuildContext context) { color: #569cd6;](return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Slider( value: _value, onChanged: (color: #569cd6;](double newValue) { setState(() ); }, ) ); }}</p> <p>Here is the output of this code. You can change the slider using touch. ![](../../Uploads/16abe337-9328-4e4b-acda-8935450e0e47.PNGwidth="50%height="auto]( Thanks,Srikanth</p>


Tags: Slider;








0 Comments
Login to comment.
Recent Comments