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 |
Tags
- Row
- navigator
- ListTile
- Flutter Tutorial
- MainAxisAlignment
- Column Widget
- ListView.builder
- Flutter Example
- FutureBuilder
- Flutter 강좌
- Row Widget
- Flutter 예제
- HTTP
- InkWell
- sqlite
- listview
- Networking
- Cached Image
- WillPopScope
- Flutter 앱 배포
- Image.network
- flutter
- Snackbar
- 반석천
- node.js
- CrossAxisAlignment
- Load Image
- Scaffold
- Hello World
- AppBar
Archives
- Today
- Total
꿈꾸는 시스템 디자이너
Flutter Example - AlertDialog 본문
import 'package:flutter/material.dart';
class AlertDialogDemo extends StatelessWidget {
// Global Key of Scaffold
final scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: scaffoldKey,
appBar: AppBar(title: Text("AlertDialog Demo")),
body: Center(
child: RaisedButton(
child: Text("Show AlertDialog"),
onPressed: () {
showAlertDialog(context);
},
)),
);
}
void showAlertDialog(BuildContext context) async {
String result = await showDialog(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text('AlertDialog Demo'),
content: Text("Select button you want"),
actions: <Widget>[
FlatButton(
child: Text('OK'),
onPressed: () {
Navigator.pop(context, "OK");
},
),
FlatButton(
child: Text('Cancel'),
onPressed: () {
Navigator.pop(context, "Cancel");
},
),
],
);
},
);
scaffoldKey.currentState
..hideCurrentSnackBar()
..showSnackBar(
SnackBar(
content: Text("Result: $result"),
backgroundColor: Colors.orange,
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 앱에서도 제공됩니다.
Flutter Code Examples - Google Play 앱
Are you a beginner at Flutter? Check out the various features of Flutter through the demo. Source code for all demos is also provided.
play.google.com
'Tutorial > Flutter with App' 카테고리의 다른 글
Comments