-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_functions.dart
96 lines (89 loc) · 2.39 KB
/
common_functions.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:get/get.dart';
import 'constants.dart';
String formatDoubleToPrice(double price) {
return '${NumberFormat.currency(locale: kLocale, symbol: kCurrencySymbol).format(price)}';
}
String getFormattedDate(double epochTime) {
double microSecondsSinceEpoch = epochTime * 1000000;
var date =
new DateTime.fromMicrosecondsSinceEpoch(microSecondsSinceEpoch.toInt());
return new DateFormat("yyyy-MM-dd hh:mm a").format(date);
}
AppBar getWhiteAppBar(String title) {
return AppBar(
title: Text(title, style: TextStyle(color: Colors.black)),
backgroundColor: Colors.white,
iconTheme: IconThemeData(color: Colors.black),
);
}
Future<void> showAlertDialog(
{@required String error, String errorDetails}) async {
String contentSummary = errorDetails == null
? 'Looks like some failure in the app. You may check the details below to see whats wrong.'
: errorDetails;
Get.dialog(
AlertDialog(
title: Text('Oops! Something wrong'),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(contentSummary),
SizedBox(
height: 5.0,
),
Text(
'Details:',
style: TextStyle(fontSize: 14.0, fontStyle: FontStyle.italic),
),
Text(
error,
style: TextStyle(
fontSize: 14.0,
fontFamily: 'SourceCodePro',
),
maxLines: 6,
),
],
),
actions: <Widget>[
FlatButton(
child: Text('OK'),
onPressed: () {
Get.back();
},
)
],
),
barrierDismissible: false,
);
}
Future<void> showSimpleAlertDialog(
{@required String title, @required String details}) async {
Get.dialog(
AlertDialog(
title: Text(title),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(details),
SizedBox(
height: 5.0,
),
],
),
actions: <Widget>[
FlatButton(
child: Text('OK'),
onPressed: () {
Get.back();
},
)
],
),
barrierDismissible: false,
);
}