78 lines
No EOL
2.3 KiB
Dart
78 lines
No EOL
2.3 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:mnemo_cards/theme/themes.dart';
|
|
|
|
import '../../main.dart';
|
|
|
|
Future<void> showInfoDialog(String message, {Completer? completer}) {
|
|
final context = scaffoldKey.currentContext!;
|
|
completer ??= Completer();
|
|
final result = showDialog(
|
|
context: context,
|
|
useRootNavigator: false,
|
|
builder: (context) {
|
|
return Center(
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: Container(
|
|
margin: EdgeInsets.all(4.0.h),
|
|
padding: EdgeInsets.all(4.0.h),
|
|
height: 200.h,
|
|
width: MediaQuery.of(context).size.width * 0.8,
|
|
decoration: BoxDecoration(
|
|
color: white,
|
|
border: Border.all(
|
|
color: Colors.grey.withOpacity(0.5),
|
|
width: 1,
|
|
),
|
|
borderRadius: BorderRadius.circular(12.0),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
child: Center(
|
|
child: Text(
|
|
message,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: Navigator.of(context).pop,
|
|
child: Container(
|
|
height: 40.h,
|
|
decoration: BoxDecoration(
|
|
color: testBlue,
|
|
border: Border.all(
|
|
color: Colors.grey.withOpacity(0.5),
|
|
width: 1,
|
|
),
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
),
|
|
alignment: Alignment.center,
|
|
child: Text('Оки'),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
bool dialogClosed = false;
|
|
completer.future.then((_) {
|
|
if (!dialogClosed) {
|
|
return Navigator.of(context).pop();
|
|
}
|
|
});
|
|
return result.then((_) {
|
|
dialogClosed = true;
|
|
if (completer?.isCompleted == false) {
|
|
completer!.complete();
|
|
}
|
|
});
|
|
} |