Advertisement
joaopaulofcc

Animação final

Sep 30th, 2020
1,138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.36 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6.   @override
  7.   Widget build(BuildContext context) {
  8.     return MaterialApp(
  9.       title: 'Teste Animação',
  10.       home: Animacao(),
  11.     );
  12.   }
  13. }
  14.  
  15. class Animacao extends StatefulWidget {
  16.   @override
  17.   _AnimacaoState createState() => _AnimacaoState();
  18. }
  19.  
  20. class _AnimacaoState extends State<Animacao> {
  21.   double containerHeight = 150;
  22.   double containerWidth = 150;
  23.   bool isExpanded = false;
  24.  
  25.  
  26.   @override
  27.   Widget build(BuildContext context) {
  28.     return Scaffold(
  29.       appBar: AppBar(
  30.         title: Text('Exemplo'),
  31.       ),
  32.       body: Center(
  33.         child: GestureDetector(
  34.           onTap: () {
  35.             setState((){
  36.               isExpanded = !isExpanded;
  37.             });
  38.           },
  39.           child: AnimatedContainer(
  40.             duration: Duration(
  41.               milliseconds: 1000,
  42.             ),
  43.             curve: Curves.bounceOut,
  44.  
  45.             decoration: BoxDecoration(
  46.               borderRadius: BorderRadius.all(
  47.                 Radius.circular(isExpanded ? 32 : 4),
  48.               ),
  49.               color: isExpanded ? Colors.green : Colors.blue,
  50.             ),            
  51.             height: isExpanded ? 250 : 150,
  52.             width: isExpanded ? 250 : 150,
  53.           ),
  54.         ),
  55.       ),
  56.     );
  57.   }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement