kopia lustrzana https://gitlab.com/mysocialportal/relatica
54 wiersze
1.4 KiB
Dart
54 wiersze
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
final getIt = GetIt.instance;
|
|
|
|
String randomId() => const Uuid().v4().toString();
|
|
|
|
Future<bool?> showConfirmDialog(BuildContext context, String caption) {
|
|
return showDialog<bool>(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
title: Text(caption),
|
|
actions: <Widget>[
|
|
ElevatedButton(
|
|
child: const Text('OK'),
|
|
onPressed: () {
|
|
Navigator.pop(context, true); // showDialog() returns true
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<bool?> showYesNoDialog(BuildContext context, String caption) {
|
|
return showDialog<bool>(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
title: Text(caption),
|
|
actions: <Widget>[
|
|
ElevatedButton(
|
|
child: const Text('Yes'),
|
|
onPressed: () {
|
|
Navigator.pop(context, true); // showDialog() returns true
|
|
},
|
|
),
|
|
ElevatedButton(
|
|
child: const Text('No'),
|
|
onPressed: () {
|
|
Navigator.pop(context, false); // showDialog() returns false
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|