|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | + |
| 3 | +/// A very simple dialog to indicate that something was not implemented yet. |
| 4 | +/// |
| 5 | +/// Show it like this: |
| 6 | +/// ```dart |
| 7 | +/// onPressed: () { |
| 8 | +/// NotImplementedDialog.show(context); |
| 9 | +/// // Or: |
| 10 | +/// context.notImplementedYet(); |
| 11 | +/// }, |
| 12 | +/// ``` |
| 13 | +class NotImplementedDialog extends StatelessWidget { |
| 14 | + const NotImplementedDialog._({Key? key}) : super(key: key); |
| 15 | + |
| 16 | + static Future<void> show(BuildContext context) { |
| 17 | + return showDialog( |
| 18 | + context: context, |
| 19 | + builder: (context) => const NotImplementedDialog._(), |
| 20 | + ); |
| 21 | + } |
| 22 | + |
| 23 | + @override |
| 24 | + Widget build(BuildContext context) { |
| 25 | + return AlertDialog( |
| 26 | + title: const Text('Not implemented yet'), |
| 27 | + content: const Text('This was not implemented yet!'), |
| 28 | + actions: [ |
| 29 | + TextButton( |
| 30 | + onPressed: Navigator.of(context).pop, |
| 31 | + child: const Text('OK'), |
| 32 | + ) |
| 33 | + ], |
| 34 | + ); |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +extension NotImplementedDialogBuildContextExtension on BuildContext { |
| 39 | + /// Displays a [NotImplementedDialog]. |
| 40 | + Future<void> notImplementedYet() => NotImplementedDialog.show(this); |
| 41 | +} |
0 commit comments