import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Alert(),
);
}
}
class Alert extends StatefulWidget {
@override
_AlertState createState() => _AlertState();
}
class _AlertState extends State<Alert> {
List<String> listViewdata = [
"a",
"b",
"c",
"d",
"e",
"f",
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Expanded(
child: ListView(
children : listViewdata.map((data){
return ListTile(
title : Text(data),
);
}).toList()
),
),
Center(
child: RaisedButton(
child: Text("AlertButton"),
onPressed: (){
showAlertDialog(context);
},
),
),
],
),
);
}
showAlertDialog(BuildContext context) {
Widget okButton = FlatButton(
child: Text("OK"),
onPressed: (){
Navigator.of(context).pop();
},
);
AlertDialog alert = AlertDialog(
title: Text("title"),
content: Text("Contents"),
actions: [
okButton,
],
);
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
}
);
}
}
'인프런 - 강의 > 플루터로 앱 만들기 고고(입문)' 카테고리의 다른 글
21 - Todo App - 4 (0) | 2020.05.07 |
---|---|
20 - Todo App - 3 (0) | 2020.05.07 |
18 - Todo App - 1 (0) | 2020.05.07 |
17 - My 아이돌 앱 3 (0) | 2020.04.28 |
16 - My 아이돌 앱 2 (0) | 2020.04.27 |