|  | 
|  | 1 | +/// | 
|  | 2 | +/// Created by NieBin on 2019年6月12日 | 
|  | 3 | +/// Github: https://github.com/nb312 | 
|  | 4 | +/// Email: niebin312@gmail.com | 
|  | 5 | +/// | 
|  | 6 | +import "package:flutter/material.dart"; | 
|  | 7 | +import "package:flutter_widgets/const/_const.dart"; | 
|  | 8 | + | 
|  | 9 | +class DismissiblePage extends StatefulWidget { | 
|  | 10 | + @override | 
|  | 11 | + _DismissibleState createState() => _DismissibleState(); | 
|  | 12 | +} | 
|  | 13 | + | 
|  | 14 | +class _DismissibleState extends State<DismissiblePage> { | 
|  | 15 | + var _key = GlobalKey(); | 
|  | 16 | + | 
|  | 17 | + @override | 
|  | 18 | + Widget build(BuildContext context) { | 
|  | 19 | + return Scaffold( | 
|  | 20 | + appBar: AppBar( | 
|  | 21 | + title: Text(PageName.INTER_DISMISSIBLE), | 
|  | 22 | + ), | 
|  | 23 | + body: Dismissible( | 
|  | 24 | + key: _key, | 
|  | 25 | + child: Container( | 
|  | 26 | + constraints: BoxConstraints.expand(height: 100), | 
|  | 27 | + alignment: Alignment.center, | 
|  | 28 | + child: Text( | 
|  | 29 | + "Hello", | 
|  | 30 | + style: TextStyle(color: TEXT_BLACK, fontSize: 20), | 
|  | 31 | + ), | 
|  | 32 | + color: BLUE, | 
|  | 33 | + ), | 
|  | 34 | + background: Container( | 
|  | 35 | + color: RED_LIGHT, | 
|  | 36 | + constraints: BoxConstraints.expand(height: 100, width: 40), | 
|  | 37 | + alignment: Alignment.center, | 
|  | 38 | + child: Text( | 
|  | 39 | + "Remove", | 
|  | 40 | + style: TextStyle(color: TEXT_BLACK_LIGHT, fontSize: 10), | 
|  | 41 | + ), | 
|  | 42 | + ), | 
|  | 43 | + direction: DismissDirection.startToEnd, | 
|  | 44 | + onDismissed: (direction) { | 
|  | 45 | + print("Dissmiss"); | 
|  | 46 | + _key.currentState.dispose(); | 
|  | 47 | + }), | 
|  | 48 | + ); | 
|  | 49 | + } | 
|  | 50 | +} | 
0 commit comments