inuba_flutter_sdk 1.4.2
inuba_flutter_sdk: ^1.4.2 copied to clipboard
iNuba App SDK for Flutter - Integration library for Flutter mobile applications
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:inuba_flutter_sdk/inuba_flutter_sdk.dart';
/// Entry point of the application
void main() {
runApp(const MyApp());
}
/// Main application widget that sets up the MaterialApp
class MyApp extends StatelessWidget {
/// Creates a [MyApp] widget
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'iNuba SDK Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo),
useMaterial3: true,
),
home: const INubaSDKExampleScreen(),
);
}
}
/// Example screen that demonstrates the usage of the iNuba SDK widget
class INubaSDKExampleScreen extends StatefulWidget {
/// Creates an [INubaSDKExampleScreen] widget
const INubaSDKExampleScreen({super.key});
@override
State<INubaSDKExampleScreen> createState() => _INubaSDKExampleScreenState();
}
class _INubaSDKExampleScreenState extends State<INubaSDKExampleScreen> {
INubaSDKController controller = INubaSDKController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text('iNuba SDK Example'),
),
body: INubaSDK(
controller: controller,
// Required parameters
clientToken: 'your_client_token',
userToken: 'your_user_token',
// Optional: White label configuration
whitelabel: Whitelabel.iNuba, // or Whitelabel.custom('YourBrand')
// Optional: Environment
environment: Environment.develop, // or Environment.production
// Optional: Platform identification
platform: Platform.android, // or Platform.ios
// Optional: Display mode
displayMode: DisplayMode.inlineView, // or DisplayMode.fullScreen
// Optional: Language
language: Language.en, // or Language.es or Language.userChoice
// Optional: Unit measurement
unitMeasurement: UnitMeasurement
.metric, // or UnitMeasurement.imperial or UnitMeasurement.userChoice
// Optional: Initial deeplink
initialDeeplink: DeepLink
.showHome, // or DeepLink.showMindScreen, DeepLink.showCalendar, etc
// Required: Handle file downloads from WebView
onDownload: (url, filename, downloadAndShare) {
// Implement your download logic here
// Example: Use flutter_downloader or flutter_file_downloader packages
},
// Optional: Handle SDK close events
onClose: (reason) {
/// Implement your close logic here
///
/// Example: Navigator.pop(context, reason);
},
),
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Theme.of(context).colorScheme.primary,
selectedItemColor: Colors.white,
unselectedItemColor: Colors.white,
onTap: (value) {
switch (value) {
case 0:
controller.injectDeeplink(DeepLink.showHome);
case 1:
controller.injectDeeplink(DeepLink.showHeartRate);
case 2:
controller.injectDeeplink(DeepLink.showSteps);
}
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home_rounded),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.heart_broken_rounded),
label: 'Heart Rate',
),
BottomNavigationBarItem(
icon: Icon(Icons.do_not_step_sharp),
label: 'Steps',
),
],
),
);
}
}