"Fossies" - the Fresh Open Source Software Archive 
Member "flutter-3.7.0/examples/api/lib/material/dialog/alert_dialog.1.dart" (24 Jan 2023, 1491 Bytes) of package /linux/misc/flutter-3.7.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "alert_dialog.1.dart":
3.3.10_vs_3.7.0.
1 // Copyright 2014 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /// Flutter code sample for [AlertDialog].
6
7 import 'package:flutter/material.dart';
8
9 void main() => runApp(const MyApp());
10
11 class MyApp extends StatelessWidget {
12 const MyApp({super.key});
13
14 @override
15 Widget build(BuildContext context) {
16 return MaterialApp(
17 theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
18 home: Scaffold(
19 appBar: AppBar(title: const Text('AlertDialog Sample')),
20 body: const Center(
21 child: DialogExample(),
22 ),
23 ),
24 );
25 }
26 }
27
28 class DialogExample extends StatelessWidget {
29 const DialogExample({super.key});
30
31 @override
32 Widget build(BuildContext context) {
33 return TextButton(
34 onPressed: () => showDialog<String>(
35 context: context,
36 builder: (BuildContext context) => AlertDialog(
37 title: const Text('AlertDialog Title'),
38 content: const Text('AlertDialog description'),
39 actions: <Widget>[
40 TextButton(
41 onPressed: () => Navigator.pop(context, 'Cancel'),
42 child: const Text('Cancel'),
43 ),
44 TextButton(
45 onPressed: () => Navigator.pop(context, 'OK'),
46 child: const Text('OK'),
47 ),
48 ],
49 ),
50 ),
51 child: const Text('Show Dialog'),
52 );
53 }
54 }