Skip to content
This repository was archived by the owner on Jun 5, 2021. It is now read-only.

Migrated to null safety #21

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/flutter_user_agent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
class FlutterUserAgent {
static const MethodChannel _channel = MethodChannel('flutter_user_agent');

static Map<String, dynamic> _properties;
static Map<String, dynamic>? _properties;

/// Initialize the module.
///
Expand All @@ -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<String, dynamic> get properties {
static Map<String, dynamic>? get properties {
return _properties;
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down