Advertisement
Guest User

Untitled

a guest
Sep 13th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.77 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6.   // This widget is the root of your application.
  7.   @override
  8.   Widget build(BuildContext context) {
  9.     return MaterialApp(
  10.       title: 'Flutter Demo',
  11.       theme: ThemeData(
  12.         primarySwatch: Colors.blue,
  13.       ),
  14.       home: MyHomePage(),
  15.     );
  16.   }
  17. }
  18.  
  19. class MyHomePage extends StatefulWidget {
  20.   @override
  21.   _MyHomePageState createState() => _MyHomePageState();
  22. }
  23.  
  24. class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  25.   bool isSuccessful = false;
  26.  
  27.   @override
  28.   Widget build(BuildContext context) {
  29.     final size = MediaQuery.of(context).size;
  30.  
  31.     return Scaffold(
  32.         appBar: AppBar(),
  33.         body: Container(
  34.           color: Colors.blueGrey,
  35.           child: Column(
  36.             mainAxisAlignment: MainAxisAlignment.spaceBetween,
  37.             children: <Widget>[
  38.               Row(
  39.                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
  40.                 children: <Widget>[
  41.                   Column(
  42.                     children: <Widget>[
  43.                       DragTarget(
  44.                         builder: (context, List<String> candidateData,
  45.                             rejectedData) {
  46.                           return isSuccessful
  47.                               ? Container(
  48.                                 padding: EdgeInsets.all(8),
  49.                                   color: Colors.white,
  50.                                   height: size.height * .75,
  51.                                   width: size.width * .49,
  52.                                   child: ListView(
  53.                                     scrollDirection: Axis.vertical,
  54.                                     children: <Widget>[
  55.                                       FlutterLogo(
  56.                                         size: 50.0,
  57.                                       ),
  58.                                     ],
  59.                                   ),
  60.                                 )
  61.                               : Container(
  62.                                   color: Colors.white,
  63.                                   height: size.height * .75,
  64.                                   width: size.width * .49,
  65.                                 );
  66.                         },
  67.                         onWillAccept: (data) {
  68.                           return true;
  69.                         },
  70.                         onAccept: (data) {
  71.                           setState(() {
  72.                             isSuccessful = !isSuccessful;
  73.                           });
  74.                         },
  75.                       ),
  76.                     ],
  77.                   ),
  78.                   Column(
  79.                     children: <Widget>[
  80.                       Container(
  81.                         color: Colors.white,
  82.                         height: size.height * .75,
  83.                         width: size.width * .49,
  84.                       )
  85.                     ],
  86.                   ),
  87.                 ],
  88.               ),
  89.               Container(
  90.                 color: Colors.grey[100],
  91.                 height: size.height * .11,
  92.                 width: size.width,
  93.                 child: ListView(
  94.                   scrollDirection: Axis.horizontal,
  95.                   children: <Widget>[
  96.                     Draggable(
  97.                       data: 'Flutter',
  98.                       child: FlutterLogo(
  99.                         size: 50.0,
  100.                       ),
  101.                       feedback: FlutterLogo(
  102.                         size: 50.0,
  103.                       ),
  104.                       childWhenDragging: Container(),
  105.                     ),
  106.                   ],
  107.                 ),
  108.               )
  109.             ],
  110.           ),
  111.         ));
  112.   }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement