Created with <3 with dartpad.dev.
Created
March 13, 2023 04:46
-
-
Save aaronkelton/c94a03ac837afb15b83e5e20122c3585 to your computer and use it in GitHub Desktop.
joyful-arc-1229
This file contains 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'; | |
import 'dart:math' as math; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith( | |
scaffoldBackgroundColor: darkBlue, | |
), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
final backgroundImage = const DecorationImage( | |
image: NetworkImage( | |
'https://content.presentermedia.com/files/clipart/00003000/3871/blank_speedometer_800_wht.jpg'), | |
fit: BoxFit.cover, | |
); | |
@override | |
Widget build(BuildContext context) { | |
return Stack(children: [ | |
Container( | |
decoration: BoxDecoration( | |
color: Colors.white, | |
image: backgroundImage, | |
shape: BoxShape.circle, | |
), | |
), | |
const Needle(), | |
]); | |
} | |
} | |
class Needle extends StatefulWidget { | |
const Needle({Key? key}) : super(key: key); | |
@override | |
State<Needle> createState() => _NeedleState(); | |
} | |
class _NeedleState extends State<Needle> with TickerProviderStateMixin { | |
late final AnimationController _controller = AnimationController( | |
duration: const Duration(seconds: 2), | |
vsync: this, | |
lowerBound: 0.0, | |
upperBound: 0.5, | |
)..repeat(reverse: true); | |
late final Animation<double> _animation = CurvedAnimation( | |
parent: _controller, | |
curve: Curves.fastOutSlowIn, | |
reverseCurve: Curves.decelerate, | |
); | |
@override | |
void dispose() { | |
_controller.dispose(); | |
super.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return RotationTransition( | |
turns: _animation, | |
child: Align( | |
alignment: Alignment.center, | |
child: Transform.rotate( | |
angle: -math.pi / 1.35, | |
child: const Icon( | |
Icons.straight, | |
color: Colors.red, | |
size: 360, | |
), | |
)), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment