CustomProvider class

A custom analytics provider using callback functions.

Use this when you have a simple analytics need without creating a full provider class.

CustomProvider(
  providerName: 'my_tracker',
  onInitialize: () => print('init'),
  onPageView: (path, title, params) => print('view: $path'),
  onEvent: (name, params) => print('event: $name'),
)
Inheritance

Constructors

CustomProvider({required String providerName, void onInitialize()?, void onPageView(String path, String? title, Map<String, dynamic>? params)?, void onEvent(String name, Map<String, dynamic>? params)?, void onDispose()?})

Properties

hashCode int
The hash code for this object.
no setterinherited
name String
Human-readable name of this provider
no setteroverride
onDispose → void Function()?
final
onEvent → void Function(String name, Map<String, dynamic>? params)?
final
onInitialize → void Function()?
final
onPageView → void Function(String path, String? title, Map<String, dynamic>? params)?
final
providerName String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Cleanup resources
override
initialize() → void
Initialize the provider (inject scripts, etc.)
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setUserProperties(Map<String, dynamic> properties) → void
Set user properties
inherited
toString() String
A string representation of this object.
inherited
trackEvent({required String name, Map<String, dynamic>? parameters}) → void
Track a custom event
override
trackPageView({required String path, String? title, Map<String, dynamic>? parameters}) → void
Track a page view
override

Operators

operator ==(Object other) bool
The equality operator.
inherited