finik_sdk 0.1.1 copy "finik_sdk: ^0.1.1" to clipboard
finik_sdk: ^0.1.1 copied to clipboard

This Flutter package allows your application to integrate Finik application features.

example/lib/main.dart

import 'package:finik_sdk/finik_sdk.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() async {
  await FinikSdk.initialization(
    apiKey: '<YOUR_API_KEY>',
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Finik DEMO',
      home: FinikProvider(
        languageCode: 'en',
        onBackPressed: () => _customDialog('onBackPressed'),

        /// on development
        onSuccess: () => _customDialog('onSuccess'),

        /// on development
        onFail: (String message) => _customDialog(message),

        /// widget: GetItemHandlerWidget/CreateItemHandlerWidget
        // widget: const GetItemHandlerWidget(
        //   itemId: 'YOUR_ITEM_ID',
        // ),
        widget: const CreateItemHandlerWidget(
          accountId: 'YOUR_ACCOUNT_ID',
          nameEn: 'YOUR_NAME_EN',
          requiredFields: [
            RequiredServiceFieldInputEntity(
              fieldId: 'YOU_FIELD_ID_FOR_REQUIRED_FIELD',

              /// optional value
              value: 'YOUR_VALUE',
            ),
          ],
        ),
      ),
    );
  }
}

void _customDialog(String message) {
  Fluttertoast.showToast(
      msg: message,
      toastLength: Toast.LENGTH_SHORT,
      gravity: ToastGravity.BOTTOM,
      timeInSecForIosWeb: 1,
      backgroundColor: Colors.red,
      textColor: Colors.white,
      fontSize: 16.0);
}