getUserAgent method

Future<String> getUserAgent()

Implementation

Future<String> getUserAgent() async {
  final deviceInfo = DeviceInfoPlugin();
  final PackageInfo packageInfo = await PackageInfo.fromPlatform();
  final String version = packageInfo.version;
  final String appName = packageInfo.appName;
  String system;
  String model;

  if (Platform.isIOS) {
    final ios = await deviceInfo.iosInfo;
    system = 'iOS ${ios.systemVersion}';
    model = ios.model;
  } else {
    final android = await deviceInfo.androidInfo;
    system = 'Android ${android.version}';
    model = android.model;
  }
  return '$appName/$version ($system; $model)';
}