Skip to content

Instantly share code, notes, and snippets.

@romanejaquez
Created March 7, 2022 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romanejaquez/6653c8a5944feccb154b15736d2fc113 to your computer and use it in GitHub Desktop.
Save romanejaquez/6653c8a5944feccb154b15736d2fc113 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.yellow,
body: Center(
child: SizedBox(
height: 200,
width: 400,
child: Stack(
clipBehavior: Clip.hardEdge,
children: [
Container(color: Colors.white),
Positioned(
top: 0,
child: ImageRotate()
)
]
)
),
),
),
);
}
}
class ImageRotate extends StatefulWidget {
const ImageRotate({Key? key}) : super(key: key);
@override
_ImageRotateState createState() => _ImageRotateState();
}
class _ImageRotateState extends State<ImageRotate>
with SingleTickerProviderStateMixin {
late AnimationController animationController;
@override
void initState() {
super.initState();
animationController = AnimationController(
vsync: this,
duration: const Duration(seconds: 30),
);
animationController.repeat();
}
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
child: AnimatedBuilder(
animation: animationController,
child: SizedBox(
child: Image.network('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSQXlzT_pWukWzD6TwmDeFJKr_ZP5i1ZlECNw&usqp=CAU',
width: 400, height: 400, fit: BoxFit.contain)
),
builder: (BuildContext context, Widget? _widget) {
return Transform.rotate(
angle: animationController.value * 6.3,
child: _widget,
);
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment