Advertisement
Guest User

main.dart

a guest
Oct 16th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.79 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: 'Support Example',
  11.  
  12.       home: MyHomePage(title: 'Support Example'),
  13.     );
  14.   }
  15. }
  16.  
  17. class MyHomePage extends StatefulWidget {
  18.   MyHomePage({Key key, this.title}) : super(key: key);
  19.   final String title;
  20.  
  21.   @override
  22.   _MyHomePageState createState() => _MyHomePageState();
  23. }
  24.  
  25. class _MyHomePageState extends State<MyHomePage> {
  26.  
  27.   PointerDownEvent lastPointerDownEvent;
  28.   DragUpdateDetails lastDragUpdateDetails;
  29.  
  30.   @override
  31.   Widget build(BuildContext context) {
  32.  
  33.     return Scaffold(
  34.       appBar: AppBar(
  35.         // Here we take the value from the MyHomePage object that was created by
  36.         // the App.build method, and use it to set our appbar title.
  37.         title: Text(widget.title),
  38.       ),
  39.       body: Listener(
  40.         onPointerDown: (PointerDownEvent event) {
  41.           setState(() {
  42.             this.lastPointerDownEvent = event;
  43.             print('lastPointerDownEvent: ${lastPointerDownEvent}');
  44.           });
  45.         },
  46.  
  47.         child: GestureDetector(
  48.           onPanUpdate: (DragUpdateDetails details) {
  49.             setState(() {
  50.               this.lastDragUpdateDetails = details;
  51.             });
  52.           },
  53.  
  54.           child: Column (
  55.             children: <Widget>[
  56.               Expanded(
  57.                 child: Container(
  58.                   child: Text('lastPointerDownEvent: ${lastPointerDownEvent} \n\n lastDragUpdateDetails: $lastDragUpdateDetails'),
  59.                   color: Colors.red[200],
  60.                 ),
  61.               ),
  62.             ],
  63.           ),
  64.         ),
  65.       ),
  66.     );
  67.   }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement