Skip to content

Instantly share code, notes, and snippets.

@chooyan-eng
Created July 15, 2025 11:37
Show Gist options
  • Save chooyan-eng/68e4c781155e60d3ecc38f567f7dd939 to your computer and use it in GitHub Desktop.
Save chooyan-eng/68e4c781155e60d3ecc38f567f7dd939 to your computer and use it in GitHub Desktop.
simple demonstration of AnimatedTo
import 'package:animated_to/animated_to.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool _isTop = true;
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: _isTop
? MainAxisAlignment.start
: MainAxisAlignment.end,
children: [
AnimatedTo.curve(
globalKey: GlobalObjectKey(1),
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(8),
),
),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() => _isTop = !_isTop);
},
child: const Icon(Icons.swap_vert),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment