Piano SDK for Flutter

Installation

Add the dependency to your pubspec.yaml:

dependencies:
  piano_common: ^1.0.3

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');

See piano_consents_flutter.

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(),
);

Localization

Pass a language code to localize Piano content. It defaults to en_US:

final piano = await Piano.init(
  endpoint: PianoEndpoint.production,
  aid: '<AID>',
  language: 'fr_FR',
);

The value is available to all Piano services through piano.client.language.

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(),
);

Libraries

piano_common