zerosettle 0.0.1
zerosettle: ^0.0.1 copied to clipboard
ZeroSettle SDK for Flutter — Merchant of Record web checkout.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zerosettle/zerosettle.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
String _priceResult = '';
final _zeroSettlePlugin = ZeroSettle();
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
String platformVersion;
try {
platformVersion =
await _zeroSettlePlugin.getPlatformVersion() ??
'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Running on: $_platformVersion'),
const SizedBox(height: 24),
ElevatedButton(
onPressed: () async {
await _zeroSettlePlugin.initialize('my-secret-api-key');
print('SDK Initialize call finished!');
},
child: const Text('Initialize SDK'),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () async {
final price = await _zeroSettlePlugin.getExamplePrice();
setState(() {
_priceResult = '${price.formatted} (${price.amountMicros} micros)';
});
print('Got price: $price');
},
child: const Text('Get Example Price'),
),
if (_priceResult.isNotEmpty) ...[
const SizedBox(height: 16),
Text(_priceResult, style: const TextStyle(fontSize: 18)),
],
],
),
),
),
);
}
}