diff --git a/lib/flutter_user_agent.dart b/lib/flutter_user_agent.dart index 11312ef..da4bf18 100644 --- a/lib/flutter_user_agent.dart +++ b/lib/flutter_user_agent.dart @@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; class FlutterUserAgent { static const MethodChannel _channel = MethodChannel('flutter_user_agent'); - static Map _properties; + static Map? _properties; /// Initialize the module. /// @@ -27,28 +27,28 @@ class FlutterUserAgent { } /// Returns the device's user agent. - static String get userAgent { - return _properties['userAgent']; + static String? get userAgent { + return _properties?['userAgent']; } /// Returns the device's webview user agent. - static String get webViewUserAgent { - return _properties['webViewUserAgent']; + static String? get webViewUserAgent { + return _properties?['webViewUserAgent']; } /// Fetch a [property] that can be used to build your own user agent string. static dynamic getProperty(String property) { - return _properties[property]; + return _properties?[property]; } /// Fetch a [property] asynchronously that can be used to build your own user agent string. static dynamic getPropertyAsync(String property) async { await init(); - return _properties[property]; + return _properties?[property]; } /// Return a map of properties that can be used to generate the user agent string. - static Map get properties { + static Map? get properties { return _properties; } } diff --git a/pubspec.yaml b/pubspec.yaml index 4617469..9f085d2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ version: 1.2.2 homepage: https://github.com/j0j00/flutter_user_agent environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: