//flutter
import 'package:flutter/material.dart';
void main() {
return runApp(TestPage());
}
//リスト4.49
class TestPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'ダイアログ',
home: Scaffold(
appBar: AppBar(title: Text('ダイアログ')),
body: DialogSample()
)
);
}
}
class DialogSample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: TextButton(
onPressed: () => showDialog<void>(
context: context,
builder: (childContext) {
return SimpleDialog(
title: Text('ダイアログ'),
children: <Widget>[
SimpleDialogOption(
onPressed: () {},
child: Text('アイテム1')
),
SimpleDialogOption(
onPressed: () {},
child: Text('アイテム2')
),
SimpleDialogOption(
onPressed: () {},
child: Text('アイテム3')
)
]
);
}
),
child: Text('ダイアログ表示')
)
);
}
}