76 lines
2.2 KiB
Dart
76 lines
2.2 KiB
Dart
|
import 'dart:convert';
|
||
|
|
||
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:intl/intl.dart';
|
||
|
import 'navigation/navigation.dart';
|
||
|
|
||
|
extension StringExtension on String {
|
||
|
String capitalize() {
|
||
|
return "${this[0].toUpperCase()}${substring(1)}";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
extension EmailValidator on String {
|
||
|
bool isValidEmail() {
|
||
|
return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$')
|
||
|
.hasMatch(this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class Helpers{
|
||
|
|
||
|
static Future<bool> isNetwork() async{
|
||
|
var connectivityResult = await (Connectivity().checkConnectivity());
|
||
|
if (connectivityResult == ConnectivityResult.none) {
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
static void showPhotoSelectionDialog(Function(int) openPicker){
|
||
|
BuildContext? context = Navigation.instance.navigatorKey.currentContext;
|
||
|
if(context != null){
|
||
|
showDialog(
|
||
|
context: context,
|
||
|
builder: (context) {
|
||
|
return AlertDialog(
|
||
|
title: const Text('Choose one Option',style: TextStyle(fontSize: 15),),
|
||
|
actions: [
|
||
|
MaterialButton(
|
||
|
elevation: 0,
|
||
|
shape: RoundedRectangleBorder(
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
|
),
|
||
|
color: Colors.indigo,
|
||
|
textColor: Colors.white,
|
||
|
onPressed: () {
|
||
|
Navigation.instance.goBack();
|
||
|
openPicker(0);
|
||
|
},
|
||
|
child: const Text("Camera"),
|
||
|
),
|
||
|
MaterialButton(
|
||
|
elevation: 0,
|
||
|
shape: RoundedRectangleBorder(
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
|
),
|
||
|
color: Colors.deepPurpleAccent,
|
||
|
textColor: Colors.white,
|
||
|
onPressed: () {
|
||
|
Navigation.instance.goBack();
|
||
|
openPicker(1);
|
||
|
},
|
||
|
child: const Text("Gallery"),
|
||
|
)
|
||
|
],
|
||
|
shape: RoundedRectangleBorder(
|
||
|
borderRadius: BorderRadius.circular(15),
|
||
|
),
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|