Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Teste Animação',
- home: Animacao(),
- );
- }
- }
- class Animacao extends StatefulWidget {
- @override
- _AnimacaoState createState() => _AnimacaoState();
- }
- class _AnimacaoState extends State<Animacao> {
- double containerHeight = 150;
- double containerWidth = 150;
- bool isExpanded = false;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text('Exemplo'),
- ),
- body: Center(
- child: GestureDetector(
- onTap: () {
- setState((){
- isExpanded = !isExpanded;
- });
- },
- child: AnimatedContainer(
- duration: Duration(
- milliseconds: 1000,
- ),
- curve: Curves.bounceOut,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(
- Radius.circular(isExpanded ? 32 : 4),
- ),
- color: isExpanded ? Colors.green : Colors.blue,
- ),
- height: isExpanded ? 250 : 150,
- width: isExpanded ? 250 : 150,
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement