Created with <3 with dartpad.dev.
Created
August 18, 2023 13:52
-
-
Save TramPamPam/985b3e83087da3a52b73648604a4ac9a to your computer and use it in GitHub Desktop.
divine-peak-0296
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'; | |
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: Animated(child: Container( | |
height: 66, | |
width: 66, | |
clipBehavior: Clip.antiAlias, | |
decoration: const BoxDecoration( | |
shape: BoxShape.circle, | |
color: Color(0xFFB5B6C2), | |
), | |
child: const Center(child: Text('Emotion')), | |
) | |
), | |
), | |
), | |
); | |
} | |
} | |
class Animated extends StatefulWidget { | |
const Animated({Key? key, required this.child}) : super(key: key); | |
final Widget child; | |
@override | |
State<Animated> createState() => _AnimatedState(); | |
} | |
class _AnimatedState extends State<Animated> | |
with SingleTickerProviderStateMixin { | |
late AnimationController _controller; | |
@override | |
void initState() { | |
super.initState(); | |
// const twiceSpeed = Duration(milliseconds: 500); | |
const speed = Duration(seconds: 1); | |
/// paste controller here: | |
_controller = AnimationController( | |
duration: speed, | |
vsync: this, | |
)..repeat(reverse: true); | |
} | |
@override | |
void dispose() { | |
_controller.dispose(); | |
super.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
/// paste builder here: | |
return AnimatedBuilder( | |
animation: _controller, | |
builder: (context, child) { | |
return Transform.translate( | |
offset: Offset(0, -30 * _controller.value), | |
child: child, | |
); | |
}, | |
child: widget.child, | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Text( | |
'Hello, World!', | |
style: Theme.of(context).textTheme.headlineMedium, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment