Trainman Booking SDK
Flutter Integration Steps:
-
Add flutter plugin in dependencies:
- Use command:
flutter pub add trainman_booking_sdk
- Manually:
- Add plugin in pubspec.yaml within dependencies section dependencies: flutter: sdk: flutter #trainman_booking_sdk: ^0.1.7#
- Use command:
-
Implement
TmBookingInterface
- it has functions like
void openLoginPage(String message, String source)
void backPressed(BuildContext context)
void refreshToken(String? pastAuthToken, String source)
- it has functions like
-
Create InitiateTmBookingSdk object.
import package:trainman_booking_sdk/trainman_booking_sdk.dart class SampleCode extends StatelessWidget { const SampleCode({Key? key}) : super(key: key) @override Widget build(BuildContext context) { //trainman booking sdk return const InitiateTmBookingSdk( {super.key, required this.tmBookingInterface, this.authToken}); } }
this will automatically invoke Trainman Booking SDK.
Auth token is optional parameter. In case of refresh auth token after successful authentication you can use
updateAccessToken(String? accessToken, String? refreshToken)
NOTE: For now we have invoked a intermediate page to login test user for testing. Post Client user login integration, this step will be skipped.
-
Click on
Continue without login
button. -
For Android, make sure you have added Internet permission
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="[http://schemas.android.com/apk/res/android](http://schemas.android.com/apk/res/android)" > <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> </manifest>