tata_rewards 0.0.10 copy "tata_rewards: ^0.0.10" to clipboard
tata_rewards: ^0.0.10 copied to clipboard

tata rewards package

Tata Rewards #

Tata Rewards package lets you add a widget that supports stuffs to rewards to your Flutter app.

Installation #

  1. Add the latest version of package to your pubspec.yaml (and runflutter pub get):
dependencies:
  tata_rewards: ^0.0.10
  1. Import the package and use it in your Flutter App. flutter pub add tata_rewards

Example #

There are a number of properties that you can modify:

https://docs.google.com/spreadsheets/d/1XLEHj1LGox_S-whE9bJ5HoMCyNYrhE37eOzf-Ci0qXc/edit?usp=sharing ( but for this need to get verify from ESMAGICO)



import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:tata_rewards/tata_rewards.dart';

import 'firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  http.Client httpClient = http.Client();

  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);

  // Initialize the SDK
  await MyRewardsSdk.instance.initialize(
    httpClient: http.Client(),
    tdlToken: '',
    tplToken: '',
    debug: true,
  );
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  // This widget is the root of your application.

  @override
  void dispose() {
    //Cleans up resources by canceling active subscriptions and closing the HTTP client. Should be called when the SDK is no longer needed, typically when the app is terminating.
    MyRewardsSdk.instance.dispose();

    // TODO: implement dispose
    super.dispose();
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    MyRewardsSdk.instance.registerOnLoginCallback(() {
      // Handle post-login actions here
    });

    MyRewardsSdk.instance.registerOnLogoutCallback(() {
      // Handle post-logout actions here
    });

    // After a successful login
    MyRewardsSdk.instance.notifyLogin();

    // After a successful logout
    MyRewardsSdk.instance.notifyLogout();

    performOperationWithCountVariable();

    MyRewardsSdk.instance.cancelActiveCardCountSubscription();
  }

  Future<void> performOperationWithCountVariable() async {
    await MyRewardsSdk.instance.subscribeToActiveCardCount(
      userId: '6079545422',
      onCountChanged: (int? activeCount) {
        if (activeCount != null) {
          // Handle the update, e.g., show a dialog or update UI
        }
      },
      onError: (String error) {
        // Handle the error, e.g., show a message to the user
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: MyRewardsPage(
        title: "My Rewards",
        myRewardsPadding: 16,
        onScratchCardClick: (id, point, status) {
        },
        gap: const SizedBox(
          height: 20,
        ),
      ),
    );
  }
}





Next Goals #

  • To Add one more game with scratch card and to introduce newer one with spin the wheel Now, you can use two type of game service in the code

  • Might to going add games based on AI rewards related games on is one of the trending item to get known off