diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml
index a638500..2c981d5 100644
--- a/.github/workflows/flutter.yml
+++ b/.github/workflows/flutter.yml
@@ -16,7 +16,7 @@ jobs:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
- flutter-version: '1.22.4'
+ flutter-version: '2.0.3'
- run: flutter pub get
- run: flutter test
- run: flutter analyze --no-pub --no-current-package lib
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index 2916c6b..e6c87f7 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -1,11 +1,11 @@
PODS:
- Flutter (1.0.0)
- - Mixpanel-swift (2.8.1):
- - Mixpanel-swift/Complete (= 2.8.1)
- - Mixpanel-swift/Complete (2.8.1)
- - mixpanel_flutter (0.0.1):
+ - Mixpanel-swift (2.8.3):
+ - Mixpanel-swift/Complete (= 2.8.3)
+ - Mixpanel-swift/Complete (2.8.3)
+ - mixpanel_flutter (1.0.1):
- Flutter
- - Mixpanel-swift (= 2.8.1)
+ - Mixpanel-swift (= 2.8.3)
DEPENDENCIES:
- Flutter (from `Flutter`)
@@ -22,9 +22,9 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/mixpanel_flutter/ios"
SPEC CHECKSUMS:
- Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
- Mixpanel-swift: 9d3a2597ef015f187abae0bfa5fda5997d5e4429
- mixpanel_flutter: 78b688d373cd5f0bb5bee423e323124ba3048353
+ Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
+ Mixpanel-swift: 947354668bf7dcaff5aaf9c64232fb5bea6ff0c7
+ mixpanel_flutter: 59130decd93dbb51e1a8a258d0d9af432287768e
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
index 1d526a1..919434a 100644
--- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -2,6 +2,6 @@
+ location = "self:">
diff --git a/example/lib/analytics.dart b/example/lib/analytics.dart
index 0b2f195..eb05333 100644
--- a/example/lib/analytics.dart
+++ b/example/lib/analytics.dart
@@ -2,14 +2,14 @@ import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class MixpanelManager {
- static Mixpanel _instance;
+ static Mixpanel? _instance;
static Future init() async {
if (_instance == null) {
_instance = await Mixpanel.init("Your Mixpanel Token",
optOutTrackingDefault: false);
}
- return _instance;
+ return _instance!;
}
}
\ No newline at end of file
diff --git a/example/lib/event.dart b/example/lib/event.dart
index 7e74a9a..3caf9b2 100644
--- a/example/lib/event.dart
+++ b/example/lib/event.dart
@@ -11,10 +11,10 @@ class EventScreen extends StatefulWidget {
}
class _EventScreenState extends State {
- Mixpanel _mixpanel;
+ late final Mixpanel _mixpanel;
@override
- Future initState() {
+ initState() {
super.initState();
_initMixpanel();
}
diff --git a/example/lib/gdpr.dart b/example/lib/gdpr.dart
index 0492242..a7b53b1 100644
--- a/example/lib/gdpr.dart
+++ b/example/lib/gdpr.dart
@@ -9,7 +9,7 @@ class GDPRScreen extends StatefulWidget {
}
class _GDPRScreenState extends State {
- Mixpanel _mixpanel;
+ late final Mixpanel _mixpanel;
@override
void initState() {
diff --git a/example/lib/group.dart b/example/lib/group.dart
index c67104e..cb6492c 100644
--- a/example/lib/group.dart
+++ b/example/lib/group.dart
@@ -9,8 +9,8 @@ class GroupScreen extends StatefulWidget {
}
class _GroupScreenState extends State {
- Mixpanel _mixpanel;
- MixpanelGroup _mixpanelGroup;
+ late final Mixpanel _mixpanel;
+ late final MixpanelGroup _mixpanelGroup;
@override
void initState() {
diff --git a/example/lib/profile.dart b/example/lib/profile.dart
index 81a6bbf..85a43fa 100644
--- a/example/lib/profile.dart
+++ b/example/lib/profile.dart
@@ -9,7 +9,7 @@ class ProfileScreen extends StatefulWidget {
}
class _ProfileScreenState extends State {
- Mixpanel _mixpanel;
+ late final Mixpanel _mixpanel;
@override
void initState() {
diff --git a/example/lib/widget.dart b/example/lib/widget.dart
index cb1c06f..4801cac 100644
--- a/example/lib/widget.dart
+++ b/example/lib/widget.dart
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
class MixpanelButton extends StatelessWidget {
- MixpanelButton({@required this.onPressed, @required this.text});
+ MixpanelButton({required this.onPressed, required this.text});
final GestureTapCallback onPressed;
final String text;
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 59c933b..6e6731d 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -7,42 +7,42 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.5.0-nullsafety.1"
+ version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0-nullsafety.1"
+ version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0-nullsafety.3"
+ version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
- version: "1.2.0-nullsafety.1"
+ version: "1.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0-nullsafety.1"
+ version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
- version: "1.15.0-nullsafety.3"
+ version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
@@ -56,7 +56,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
- version: "1.2.0-nullsafety.1"
+ version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
@@ -73,28 +73,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.10-nullsafety.1"
+ version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0-nullsafety.3"
+ version: "1.3.0"
mixpanel_flutter:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
- version: "1.0.0"
+ version: "1.0.1"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.0-nullsafety.1"
+ version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
@@ -106,56 +106,56 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.0-nullsafety.2"
+ version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
- version: "1.10.0-nullsafety.1"
+ version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0-nullsafety.1"
+ version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0-nullsafety.1"
+ version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
- version: "1.2.0-nullsafety.1"
+ version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.19-nullsafety.2"
+ version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0-nullsafety.3"
+ version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0-nullsafety.3"
+ version: "2.1.0"
sdks:
- dart: ">=2.10.0-110 <2.11.0"
+ dart: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 7326b49..f236489 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -4,7 +4,7 @@ description: Demonstrates how to use the mixpanel_flutter plugin.
publish_to: 'none'
environment:
- sdk: ">=2.7.0 <3.0.0"
+ sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
diff --git a/lib/mixpanel_flutter.dart b/lib/mixpanel_flutter.dart
index 194c48e..00028cf 100644
--- a/lib/mixpanel_flutter.dart
+++ b/lib/mixpanel_flutter.dart
@@ -11,13 +11,12 @@ class Mixpanel {
'mp_lib': 'flutter',
};
- String _token;
- People _people;
+ final String _token;
+ final People _people;
- Mixpanel(String token) {
- this._token = token;
- this._people = new People(token);
- }
+ Mixpanel(String token)
+ : _token = token,
+ _people = new People(token);
///
/// Initializes an instance of the API with the given project token.
@@ -30,10 +29,7 @@ class Mixpanel {
{bool optOutTrackingDefault = false}) async {
var properties = {'token': token};
- if (optOutTrackingDefault != null) {
- properties['optOutTrackingDefault'] = optOutTrackingDefault;
- }
-
+ properties['optOutTrackingDefault'] = optOutTrackingDefault;
properties['mixpanelProperties'] = _mixpanelProperties;
await _channel.invokeMethod('initialize', properties);
@@ -68,6 +64,7 @@ class Mixpanel {
/// * [loggingEnabled] whether to enable logging
void setLoggingEnabled(bool loggingEnabled) {
if (Platform.isIOS) {
+ // ignore: unnecessary_null_comparison
if (loggingEnabled != null) {
_channel.invokeMethod('setLoggingEnabled',
{'loggingEnabled': loggingEnabled});
@@ -81,7 +78,7 @@ class Mixpanel {
/// Will return true if the user has opted out from tracking.
/// return true if user has opted out from tracking. Defaults to false.
- Future hasOptedOutTracking() async {
+ Future hasOptedOutTracking() async {
return await _channel.invokeMethod('hasOptedOutTracking');
}
@@ -101,7 +98,6 @@ class Mixpanel {
_channel.invokeMethod('optOutTracking');
}
-
/// Associate all future calls to track() with the user identified by
/// the given distinct id.
///
@@ -161,7 +157,7 @@ class Mixpanel {
///
/// * [eventName] The name of the event to send
/// * [properties] An optional map containing the key value pairs of the properties to include in this event.
- void track(String eventName, {Map properties}) {
+ void track(String eventName, {Map? properties}) {
if (_MixpanelHelper.isValidString(eventName)) {
_channel.invokeMethod('track',
{'eventName': eventName, 'properties': properties});
@@ -326,7 +322,7 @@ class Mixpanel {
/// and persist beyond the lifetime of your application.
///
/// return Super properties for this Mixpanel instance.
- Future