Skip to content

Instantly share code, notes, and snippets.

@flexboni
Created December 5, 2023 05:28
Show Gist options
  • Save flexboni/fb84ab69806dcfe1f3fe9fee23b7d8bb to your computer and use it in GitHub Desktop.
Save flexboni/fb84ab69806dcfe1f3fe9fee23b7d8bb to your computer and use it in GitHub Desktop.
플러터챌린지 7일차 심화문제 - 김구봉
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Challenge',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
List<Widget> children = [];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: children,
),
floatingActionButton: FloatingActionButton(
onPressed: () {
AnimationController controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 3),
);
controller.forward().whenComplete(() {
controller.reset();
controller.dispose();
children.removeAt(0);
setState(() {});
});
children.add(
SlideTransition(
position: Tween<Offset>(
begin: const Offset(12.5, 30),
end: const Offset(12, 15),
).animate(controller),
child: const Icon(Icons.favorite),
),
);
setState(() {});
},
child: const Icon(Icons.favorite),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment