backup.
This commit is contained in:
6
lib/utils/extensions.dart
Normal file
6
lib/utils/extensions.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
extension StringCap on String {
|
||||
String get firstCap => '${this[0].toUpperCase()}${this.substring(1)}';
|
||||
String get allCaps => this.toUpperCase();
|
||||
String get eachFirstCap => this.split(" ").map((str) => str.firstCap).join(" ");
|
||||
}
|
||||
@@ -35,9 +35,10 @@ class HttpUtil {
|
||||
'Http-Business-Id': '0',
|
||||
'Http-App-Key': '',
|
||||
'Http-Contact-Authorization': '',
|
||||
'Http-Device-Type': Platform.isIOS ? 'ios' : (Platform.isAndroid ? 'android' : 'web'),
|
||||
'Http-Device-Type': Utils.getOs(checkWeb: true),
|
||||
'Http-Api-Branch': 'flutter',
|
||||
'Http-Language-Code': store.state.locale.languageCode,
|
||||
'Http-Country-Code': store.state.locale.countryCode,
|
||||
};
|
||||
|
||||
static Future<dynamic> httpGet(String url,
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:hive/hive.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:universal_io/io.dart';
|
||||
import '../constants.dart';
|
||||
import 'util_web.dart' if (dart.library.io) 'util_io.dart';
|
||||
|
||||
import '../routes.dart';
|
||||
@@ -267,6 +268,47 @@ class Utils {
|
||||
onError(error);
|
||||
});
|
||||
}
|
||||
|
||||
static String getOs({bool checkWeb = false}) {
|
||||
if (checkWeb && kIsWeb) {
|
||||
return 'web';
|
||||
}
|
||||
if (Platform.isAndroid) {
|
||||
return 'android';
|
||||
}
|
||||
if (Platform.isIOS) {
|
||||
return 'ios';
|
||||
}
|
||||
if (Platform.isLinux) {
|
||||
return 'ubuntu';
|
||||
}
|
||||
if (Platform.isMacOS) {
|
||||
return 'mac';
|
||||
}
|
||||
if (Platform.isWindows) {
|
||||
return 'windows';
|
||||
}
|
||||
return 'web';
|
||||
}
|
||||
|
||||
static int getOsFontHex(String os) {
|
||||
if (os == 'mac') {
|
||||
return Constants.FONT_APPLE;
|
||||
}
|
||||
if (os == 'windows') {
|
||||
return Constants.FONT_WINDOWS;
|
||||
}
|
||||
if (os == 'ubuntu') {
|
||||
return Constants.FONT_UBUNTU;
|
||||
}
|
||||
if (os == 'android') {
|
||||
return Constants.FONT_ANDROID;
|
||||
}
|
||||
if (os == 'ios') {
|
||||
return Constants.FONT_IOS;
|
||||
}
|
||||
return Constants.FONT_TOPTONS;
|
||||
}
|
||||
}
|
||||
|
||||
class RuntimeError extends Error{
|
||||
|
||||
Reference in New Issue
Block a user