Skip to content

Instantly share code, notes, and snippets.

@aaronkelton
Created March 13, 2023 04:47
Show Gist options
  • Save aaronkelton/0e4411e53d86c51aed685613669b27f3 to your computer and use it in GitHub Desktop.
Save aaronkelton/0e4411e53d86c51aed685613669b27f3 to your computer and use it in GitHub Desktop.
joyful-arc-1229
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