Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: MyHomePage(),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- @override
- _MyHomePageState createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
- bool isSuccessful = false;
- @override
- Widget build(BuildContext context) {
- final size = MediaQuery.of(context).size;
- return Scaffold(
- appBar: AppBar(),
- body: Container(
- color: Colors.blueGrey,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Column(
- children: <Widget>[
- DragTarget(
- builder: (context, List<String> candidateData,
- rejectedData) {
- return isSuccessful
- ? Container(
- padding: EdgeInsets.all(8),
- color: Colors.white,
- height: size.height * .75,
- width: size.width * .49,
- child: ListView(
- scrollDirection: Axis.vertical,
- children: <Widget>[
- FlutterLogo(
- size: 50.0,
- ),
- ],
- ),
- )
- : Container(
- color: Colors.white,
- height: size.height * .75,
- width: size.width * .49,
- );
- },
- onWillAccept: (data) {
- return true;
- },
- onAccept: (data) {
- setState(() {
- isSuccessful = !isSuccessful;
- });
- },
- ),
- ],
- ),
- Column(
- children: <Widget>[
- Container(
- color: Colors.white,
- height: size.height * .75,
- width: size.width * .49,
- )
- ],
- ),
- ],
- ),
- Container(
- color: Colors.grey[100],
- height: size.height * .11,
- width: size.width,
- child: ListView(
- scrollDirection: Axis.horizontal,
- children: <Widget>[
- Draggable(
- data: 'Flutter',
- child: FlutterLogo(
- size: 50.0,
- ),
- feedback: FlutterLogo(
- size: 50.0,
- ),
- childWhenDragging: Container(),
- ),
- ],
- ),
- )
- ],
- ),
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement