Created
November 22, 2021 16:39
-
-
Save IsmailAlamKhan/b4ccd0c6a2dca5b6c1b6b6245006fcce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Material App', | |
home: Scaffold( | |
appBar: AppBar(title: const Text('Material App Bar')), | |
body: const Center(child: Home()), | |
), | |
); | |
} | |
} | |
class Home extends StatefulWidget { | |
const Home({Key? key}) : super(key: key); | |
@override | |
_HomeState createState() => _HomeState(); | |
} | |
class _HomeState extends State<Home> with SingleTickerProviderStateMixin { | |
late final AnimationController _controller; | |
@override | |
void initState() { | |
_controller = AnimationController.unbounded( | |
vsync: this, | |
duration: const Duration(seconds: 2), | |
value: 0, | |
)..animateTo(10); | |
super.initState(); | |
} | |
@override | |
void dispose() { | |
_controller.dispose(); | |
super.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return AnimatedBuilder( | |
animation: _controller, | |
builder: (context, __) { | |
return Slider( | |
min: 0.0, | |
max: 10, | |
value: _controller.value, | |
onChanged: (value) => _controller.value = value, | |
); | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment