joaopaulofcc

Animação 1

Sep 30th, 2020
746
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  24.  
  25.   @override
  26.   Widget build(BuildContext context) {
  27.     return Scaffold(
  28.       appBar: AppBar(
  29.         title: Text('Example'),
  30.       ),
  31.       body: Center(
  32.         child: GestureDetector(
  33.           onTap: () {
  34.             setState((){
  35.               containerHeight = containerHeight == 150 ? 250 : 150;
  36.               containerWidth = containerWidth == 150 ? 250 : 150;
  37.             });
  38.           },
  39.           child: Container(
  40.             color: Colors.blue,
  41.             height: containerHeight,
  42.             width: containerWidth,
  43.           ),
  44.         ),
  45.       ),
  46.     );
  47.   }
  48. }
RAW Paste Data