728x90
반응형

import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
home: Scaffold(
appBar: AppBar(title: const Text('AlertDialog Sample')),
body: const Center(
child: DialogExample(),
),
),
);
}
}
class DialogExample extends StatelessWidget {
const DialogExample({super.key});
@override
Widget build(BuildContext context) {
return TextButton(
onPressed: () => showDialog<String>(
context: context,
builder: (BuildContext context) => AlertDialog(
title: const Text('AlertDialog Title'),
content: const Text('AlertDialog description'),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context, 'Cancel'),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, 'OK'),
child: const Text('OK'),
),
],
),
),
child: const Text('Show Dialog'),
);
}
}
https://api.flutter.dev/flutter/material/AlertDialog-class.html
728x90
반응형
'Flutter(dart)' 카테고리의 다른 글
| Flutter flexible/expanded (0) | 2022.12.14 |
|---|---|
| 플러터 Inkwell (0) | 2022.12.14 |
| A package may not list itself as a dependency (0) | 2022.11.29 |
| The overflowing RenderFlex has an orientation of Axis.vertical. (0) | 2022.11.23 |
| flutter inkwell gesturedetector 이벤트 (0) | 2022.11.16 |