Advertisement
AbiMulya

(Belajar Flutter) Flexible Widget + ANimated Container

Oct 7th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.47 KB | None | 0 0
  1. import 'dart:math';
  2.  
  3. import 'package:flutter/material.dart';
  4.  
  5. void main() {
  6.   runApp(MyApp());
  7. }
  8.  
  9. class MyApp extends StatefulWidget {
  10.   @override
  11.   _MyAppState createState() => _MyAppState();
  12. }
  13.  
  14. class _MyAppState extends State<MyApp> {
  15.   Random random = Random();
  16.   @override
  17.   Widget build(BuildContext context) {
  18.     return MaterialApp(
  19.       home: Scaffold(
  20.         appBar: AppBar(
  21.           title: Text("Flexible Layout"),
  22.         ),
  23.         body: Column(
  24.           children: <Widget>[
  25.             Flexible(
  26.               child: Row(
  27.                 children: <Widget>[
  28.                   Flexible(
  29.                       flex: random.nextInt(2),
  30.                       child: GestureDetector(
  31.                         onTap: () {
  32.                           setState(() {});
  33.                         },
  34.                         child: AnimatedContainer(
  35.                           margin: EdgeInsets.all(5),
  36.                           color: Color.fromARGB(255, random.nextInt(256),
  37.                               random.nextInt(256), random.nextInt(256)),
  38.                           duration: Duration(seconds: 1),
  39.                         ),
  40.                       )),
  41.                   Flexible(
  42.                       flex: random.nextInt(2),
  43.                       child: GestureDetector(
  44.                         onTap: () {
  45.                           setState(() {});
  46.                         },
  47.                         child: AnimatedContainer(
  48.                           margin: EdgeInsets.all(5),
  49.                           color: Color.fromARGB(255, random.nextInt(256),
  50.                               random.nextInt(256), random.nextInt(256)),
  51.                           duration: Duration(seconds: 1),
  52.                         ),
  53.                       )),
  54.                   Flexible(
  55.                       flex: random.nextInt(2),
  56.                       child: GestureDetector(
  57.                         onTap: () {
  58.                           setState(() {});
  59.                         },
  60.                         child: AnimatedContainer(
  61.                           margin: EdgeInsets.all(5),
  62.                           color: Color.fromARGB(255, random.nextInt(256),
  63.                               random.nextInt(256), random.nextInt(256)),
  64.                           duration: Duration(seconds: 1),
  65.                         ),
  66.                       ))
  67.                 ],
  68.               ),
  69.             ),
  70.             Flexible(
  71.                 flex: random.nextInt(2),
  72.                 child: GestureDetector(
  73.                   onTap: () {
  74.                     setState(() {});
  75.                   },
  76.                   child: AnimatedContainer(
  77.                     margin: EdgeInsets.all(5),
  78.                     color: Color.fromARGB(255, random.nextInt(256),
  79.                         random.nextInt(256), random.nextInt(256)),
  80.                     duration: Duration(seconds: 1),
  81.                   ),
  82.                 )),
  83.             Flexible(
  84.                 flex: random.nextInt(2),
  85.                 child: GestureDetector(
  86.                   onTap: () {
  87.                     setState(() {});
  88.                   },
  89.                   child: AnimatedContainer(
  90.                     margin: EdgeInsets.all(5),
  91.                     color: Color.fromARGB(255, random.nextInt(256),
  92.                         random.nextInt(256), random.nextInt(256)),
  93.                     duration: Duration(seconds: 1),
  94.                   ),
  95.                 ))
  96.           ],
  97.         ),
  98.       ),
  99.     );
  100.   }
  101. }
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement