dart_image_slider 0.0.1 dart_image_slider: ^0.0.1 copied to clipboard
Easy way to add image as the Slider thumb
import 'package:flutter/material.dart';
import 'package:dart_image_slider/dart_image_slider.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Dart Image Slider'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
var _currentValue = 0.0;
Slider _getSlider() {
return Slider(
value: _currentValue,
max: 100,
divisions: 10,
label: _currentValue.round().toString(),
onChanged: (double value) {
setState(() {
_currentValue = value;
});
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: DartImageSlider(
slider: _getSlider(),
imagePath: 'assets/button.png',
));
}
}