Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- ListTile
- Flutter Tutorial
- HTTP
- flutter
- AppBar
- Snackbar
- Flutter 강좌
- Flutter 예제
- Scaffold
- CrossAxisAlignment
- Networking
- listview
- WillPopScope
- 반석천
- sqlite
- FutureBuilder
- Cached Image
- Image.network
- Flutter 앱 배포
- node.js
- Row
- MainAxisAlignment
- Row Widget
- InkWell
- Column Widget
- Hello World
- navigator
- Flutter Example
- Load Image
- ListView.builder
Archives
- Today
- Total
꿈꾸는 시스템 디자이너
Flutter Example - GestureDetector | InkWell 본문
import 'package:flutter/material.dart';
GestureDetectorDemoState pageState;
class GestureDetectorDemo extends StatefulWidget {
@override
State<StatefulWidget> createState() {
pageState = GestureDetectorDemoState();
return pageState;
}
}
class GestureDetectorDemoState extends State<GestureDetectorDemo> {
final scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: scaffoldKey,
appBar: AppBar(title: Text("GestureDetector & InkWell")),
body: ListView(
children: <Widget>[
myTitle("InkWell"),
InkWell(
child: Container(
height: 50,
color: Colors.orange,
alignment: Alignment(0, 0),
margin: const EdgeInsets.all(10),
child: Text(
"Container with Text in InkWell\nTap me!!",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
),
onTap: () {
showSnackBar("InkWell - onTap");
},
onDoubleTap: () {
showSnackBar("InkWell - onDoubleTap");
},
onTapDown: (value) {
showSnackBar("InkWell - onTapDown");
},
onTapCancel: () {
showSnackBar("InkWell - onTapCancel");
},
onLongPress: () {
showSnackBar("InkWell - onLongPress");
},
),
myTitle("Gesture Detector"),
GestureDetector(
child: Container(
height: 50,
color: Colors.blue,
alignment: Alignment(0, 0),
margin: const EdgeInsets.all(10),
child: Text(
"Container with Text in GestureDetector\nTap me!!",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
),
onTap: () {
showSnackBar("GestureDetector - onTap");
},
onDoubleTap: () {
showSnackBar("GestureDetector - onDoubleTap");
},
onTapDown: (value) {
showSnackBar("GestureDetector - onTapDown");
},
onTapCancel: () {
showSnackBar("GestureDetector - onTapCancel");
},
onLongPress: () {
showSnackBar("GestureDetector - onLongPress");
},
)
],
),
);
}
myTitle(String title) {
return Column(
children: <Widget>[
Container(
alignment: Alignment(-1, 0),
padding: const EdgeInsets.only(left: 10, top: 10, bottom: 5),
child: Text(
"* $title",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
Divider(
color: Colors.grey,
height: 0,
indent: 10,
endIndent: 10,
)
],
);
}
showSnackBar(String message) {
scaffoldKey.currentState
..hideCurrentSnackBar()
..showSnackBar(
SnackBar(
content: Text(message),
backgroundColor: Colors.blue,
action: SnackBarAction(
label: "Done",
textColor: Colors.white,
onPressed: () {},
),
),
);
}
}
▶ Go to Table of Contents | 강의 목차로 이동
※ This example is also available in the Flutter Code Examples app. | 본 예제는 Flutter Code Examples 앱에서도 제공됩니다.
'Tutorial > Flutter with App' 카테고리의 다른 글
Flutter Example - Admob Plugin | How to use admob_flutter (2) | 2019.09.30 |
---|---|
Flutter Example - Screen Orientations (0) | 2019.09.30 |
Flutter Example - Buttons | FlatButton / OutlineButton / RaisedButton / IconButton / FloatingActionButton (1) | 2019.09.30 |
Flutter Example - ListView | Handle Items | Insert & remove items (2) | 2019.09.30 |
Flutter Example - GridView Widget (0) | 2019.09.27 |
Comments