piano_common 1.0.1
piano_common: ^1.0.1 copied to clipboard
Common package for Piano Flutter SDK.
Piano SDK for Flutter #
Installation #
Add the dependency to your pubspec.yaml:
dependencies:
piano_common: ^1.0.1
Getting Started #
Initialize the SDK with your Application ID (AID) and an endpoint:
import 'package:piano_common/piano_common.dart';
final piano = await Piano.init(
endpoint: PianoEndpoint.production,
aid: '<AID>',
);
Endpoints #
Use one of the predefined regional endpoints or define a custom one:
// Predefined endpoints
PianoEndpoint.production // Global
PianoEndpoint.productionEurope // EU
PianoEndpoint.productionAustralia // Australia
PianoEndpoint.productionAsiaPacific // Asia-Pacific
PianoEndpoint.sandbox // Sandbox
// Custom endpoint
final custom = PianoEndpoint(
api: 'https://api.piano.io',
composer: 'https://c2.piano.io',
id: 'https://id.piano.io',
);
// Single-URL endpoint (all services on the same host)
final local = PianoEndpoint.fromUrl('http://localhost:8080');
Consent Configuration #
Optionally pass a PianoConsentConfiguration to control consent behavior:
import 'package:piano_consents_flutter/piano_consents_flutter.dart';
final piano = await Piano.init(
endpoint: PianoEndpoint.production,
aid: '<AID>',
consentConfig: PianoConsentConfiguration(),
);
Logging #
Enable debug logging by providing a Logger instance:
import 'package:logger/logger.dart';
final piano = await Piano.init(
endpoint: PianoEndpoint.sandbox,
aid: '<AID>',
logger: Logger(),
);