Advertisement
AbiMulya

(Belajar Flutter) Animated Container & GestureDetector

Oct 7th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.96 KB | None | 0 0
  1. import 'dart:math';
  2. import 'package:flutter/material.dart';
  3.  
  4. void main() {
  5.   runApp(MyApp());
  6. }
  7.  
  8. class MyApp extends StatefulWidget {
  9.   @override
  10.   _MyAppState createState() => _MyAppState();
  11. }
  12.  
  13. class _MyAppState extends State<MyApp> {
  14.   Random random = Random();
  15.   @override
  16.   Widget build(BuildContext context) {
  17.     return MaterialApp(
  18.       home: Scaffold(
  19.         appBar: AppBar(
  20.           title: Text("Latihan Animated Container"),
  21.         ),
  22.         body: Center(
  23.           child: GestureDetector(
  24.             onTap: () {
  25.               setState(() {});
  26.             },
  27.             child: AnimatedContainer(
  28.               color: Color.fromARGB(255, random.nextInt(256),
  29.                   random.nextInt(256), random.nextInt(256)),
  30.               duration: Duration(seconds: 1),
  31.               width: 50.0 + random.nextInt(101),
  32.               height: 50.00 + random.nextInt(101),
  33.             ),
  34.           ),
  35.         ),
  36.       ),
  37.     );
  38.   }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement