import 'dart:io';

import 'package:electronic_assistant/device/atmob_platform_info.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

bool getBoolValue(bool? value) {
  return value ?? false;
}

String stringToUnicode(String input) {
  StringBuffer unicodeString = StringBuffer();
  for (int i = 0; i < input.length; i++) {
    unicodeString
        .write('\\u${input.codeUnitAt(i).toRadixString(16).padLeft(4, '0')}');
  }
  return unicodeString.toString();
}

String? getDeviceId() {
  if (Platform.isAndroid) {
    return atmobPlatformInfo.androidId;
  } else if (Platform.isIOS) {
    return atmobPlatformInfo.idfv;
  }
  return null;
}

void backToSpecificPage(String targetRoute) {
  Get.until((route) => Get.currentRoute == targetRoute);
}

bool isNumeric(String str) {
  final numericRegex = RegExp(r'^-?[0-9]+$');
  return numericRegex.hasMatch(str);
}