|
|
@ -1,8 +1,11 @@ |
|
|
|
import 'package:meta/meta.dart'; |
|
|
|
import 'package:meta/meta.dart'; |
|
|
|
import 'package:package_info_plus/package_info_plus.dart'; |
|
|
|
import 'package:package_info_plus/package_info_plus.dart'; |
|
|
|
|
|
|
|
|
|
|
|
late String? _userAgent; |
|
|
|
String? _userAgent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Sets the user agent. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// It can be accessed with [neonUserAgent]. |
|
|
|
@internal |
|
|
|
@internal |
|
|
|
void buildUserAgent(final PackageInfo packageInfo) { |
|
|
|
void buildUserAgent(final PackageInfo packageInfo) { |
|
|
|
var buildNumber = packageInfo.buildNumber; |
|
|
|
var buildNumber = packageInfo.buildNumber; |
|
|
@ -12,5 +15,13 @@ void buildUserAgent(final PackageInfo packageInfo) { |
|
|
|
_userAgent = 'Neon ${packageInfo.version}+$buildNumber'; |
|
|
|
_userAgent = 'Neon ${packageInfo.version}+$buildNumber'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Gets the current user agent. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// It must be set by calling [buildUserAgent] before. If not set a [StateError] will be thrown. |
|
|
|
@internal |
|
|
|
@internal |
|
|
|
String get neonUserAgent => _userAgent!; |
|
|
|
String get neonUserAgent { |
|
|
|
|
|
|
|
if (_userAgent == null) { |
|
|
|
|
|
|
|
throw StateError('The user agent has not been set up. Please use `buildUserAgent` before.'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return _userAgent!; |
|
|
|
|
|
|
|
} |
|
|
|