You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.4 KiB
Dart
94 lines
2.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../config/size_config.dart';
|
|
import '../util/dr_app_toast_msg.dart';
|
|
|
|
import 'package:connectivity/connectivity.dart';
|
|
|
|
|
|
DrAppToastMsg toastMsg = DrAppToastMsg();
|
|
/*
|
|
*@author: Elham Rababah
|
|
*@Date:12/4/2020
|
|
*@param:
|
|
*@return:
|
|
*@desc: This class will contian some Function will help developer
|
|
*/
|
|
class Helpers {
|
|
/*
|
|
*@author: Elham Rababah
|
|
*@Date:12/4/2020
|
|
*@param: context, items, decKey, onSelectFun
|
|
*@return: Container Widget
|
|
*@desc: showCupertinoPicker its a general function to show cupertino picker
|
|
*/
|
|
showCupertinoPicker(context, items, decKey, onSelectFun) {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
builder: (BuildContext builder) {
|
|
return Container(
|
|
height: SizeConfig.realScreenHeight * .3,
|
|
child: buildPickerItems(context, items, decKey, onSelectFun));
|
|
});
|
|
}
|
|
|
|
/*
|
|
*@author: Elham Rababah
|
|
*@Date:12/4/2020
|
|
*@param: context, List items, decKey, onSelectFun
|
|
*@return: Container widget
|
|
*@desc: buildPickerIterm this function will build the items of the cupertino
|
|
*/
|
|
buildPickerItems(context, List items, decKey, onSelectFun) {
|
|
return Container(
|
|
child: CupertinoPicker(
|
|
magnification: 1.5,
|
|
// backgroundColor: Colors.black87,
|
|
children: items.map((item) {
|
|
return Text(
|
|
'${item["$decKey"]}',
|
|
style:
|
|
TextStyle(color: Theme.of(context).primaryColor, fontSize: 20),
|
|
);
|
|
}).toList(),
|
|
|
|
itemExtent: 25, //height of each item
|
|
looping: true,
|
|
onSelectedItemChanged: (int index) {
|
|
// selectitem =index;
|
|
onSelectFun(index);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
showErrorToast([msg = null]) {
|
|
String localMsg = 'Something wrong happened, please contact the admin';
|
|
|
|
if (msg != null) {
|
|
localMsg = msg.toString();
|
|
}
|
|
|
|
toastMsg.showErrorToast(localMsg);
|
|
}
|
|
|
|
/*
|
|
*@author: Mohammad Aljammal
|
|
*@Date:27/4/2020
|
|
*@param:
|
|
*@return: Boolean
|
|
*@desc: Check The Internet Connection
|
|
*/
|
|
static Future<bool> checkConnection() async {
|
|
ConnectivityResult connectivityResult =
|
|
await (Connectivity().checkConnectivity());
|
|
if ((connectivityResult == ConnectivityResult.mobile) ||
|
|
(connectivityResult == ConnectivityResult.wifi)) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|