flutter_pixalate_collect 1.0.0
flutter_pixalate_collect: ^1.0.0 copied to clipboard
Flutter package for Pixalate data collection - compatible with both iOS and Android
flutter_pixalate_collect #
A Flutter package for Pixalate data collection that works on both iOS and Android.
Features #
- ✅ Compatible with iOS and Android
- ✅ Automatic session and visitor tracking
- ✅ Geolocation support (with fallback)
- ✅ Persistent storage using SharedPreferences
- ✅ Widget and Service APIs
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
flutter_pixalate_collect: ^1.0.0
Then run:
flutter pub get
Permissions #
iOS (Info.plist) #
Add to ios/Runner/Info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to provide better analytics</string>
Android (AndroidManifest.xml) #
Add to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Usage #
Using the Widget #
import 'package:flutter/material.dart';
import 'package:flutter_pixalate_collect/flutter_pixalate_collect.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Column(
children: [
PixalateCollect(
networkcode: "23269931309",
partnerId: "n/a",
currentDomain: "http://sorbet-supply.test",
clientId: "ask.askaianything.ai",
onSuccess: (payload) {
print('Data sent: $payload');
},
onError: (error) {
print('Error: $error');
},
),
// Your app content
],
),
),
);
}
}
Using the Service #
import 'package:flutter/material.dart';
import 'package:flutter_pixalate_collect/flutter_pixalate_collect.dart';
class MyScreen extends StatefulWidget {
@override
_MyScreenState createState() => _MyScreenState();
}
class _MyScreenState extends State<MyScreen> {
late PixalateCollectService _service;
@override
void initState() {
super.initState();
_service = PixalateCollectService(
PixalateCollectConfig(
networkcode: "23269931309",
partnerId: "n/a",
currentDomain: "http://sorbet-supply.test",
clientId: "ask.askaianything.ai",
pageUri: "app://my-screen",
onSuccess: (payload) {
print('Data sent: $payload');
},
onError: (error) {
print('Error: $error');
},
),
);
// Automatically collect on initialization
_service.initialize();
}
// Manually trigger collection
void _handleButtonPress() {
_service.collectData(customPageUri: 'app://custom-page');
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: _handleButtonPress,
child: Text('Collect Data'),
),
),
);
}
}
API Reference #
PixalateCollect Widget #
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
networkcode |
String |
Yes | - | Network code |
partnerId |
String |
No | "n/a" |
Partner ID |
currentDomain |
String |
Yes | - | API endpoint domain |
clientId |
String |
No | "ask.askaianything.ai" |
Client ID |
onError |
Function(dynamic) |
No | - | Error callback |
onSuccess |
Function(Map<String, dynamic>) |
No | - | Success callback |
PixalateCollectService #
Constructor
PixalateCollectService(PixalateCollectConfig config)
PixalateCollectConfig
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
networkcode |
String |
Yes | - | Network code |
partnerId |
String |
No | "n/a" |
Partner ID |
currentDomain |
String |
Yes | - | API endpoint domain |
clientId |
String |
No | "ask.askaianything.ai" |
Client ID |
pageUri |
String |
No | "app://main" |
Page URI |
onError |
Function(dynamic) |
No | - | Error callback |
onSuccess |
Function(Map<String, dynamic>) |
No | - | Success callback |
Methods
| Method | Description |
|---|---|
initialize() |
Initialize and collect data (only once) |
collectData({String? customPageUri}) |
Manually trigger data collection |
Data Collected #
The package collects and sends the following data:
browserAgent: User agent stringclientId: Client identifiernetworkcode: Network codepartnerId: Partner IDpageUri: Current page URIsessionId: Session identifiersessionTime: Session timestampvisitorId: Visitor identifier (persists for 365 days)visitorTime: Visitor timestampsupplyType: Always "Mobile_Web" for FluttermobileLatitude: Device latitude (if permission granted)mobileLongitude: Device longitude (if permission granted)
Notes #
- Session data persists until app is uninstalled or cleared
- Visitor data persists for 365 days
- Location is optional and will be
nullif permission is denied - The package automatically handles location permissions
- If location permissions are not granted, the package will still send data without location
License #
MIT