nudge_core 0.0.19 copy "nudge_core: ^0.0.19" to clipboard
nudge_core: ^0.0.19 copied to clipboard

The Official core package to enable Nudge tracking and in-app experiences in your Flutter app by Nudge (www.nudgenow.com).

Overview #

The Nudge Flutter Package allows you to integrate the core analytics and experience triggering nudge package provided by Nudge into your Flutter application. With this package, you can engage your users with interactive games and promotions.

Getting Started #

To get started with the Nudge Flutter Package, follow these steps:

  1. Navigate to Nudge's official website to explore the in-app experiences you can enable in your app.
  2. Register your product on our website Nudge.
  3. From the Nudge website, you will obtain a unique secret key. Use this secret key while initializing the package.

Usage #

After adding the NudgeCore package to your project's dependencies in the pubspec.yaml file, you need to run flutter pub get command to fetch the package and make it accessible in your Flutter project. This command will download the package and its dependencies, allowing you to import and utilize the Nudge package in your code.

To initialize the NudgeCore class with a reusable variable name and access all its functions through it, follow these steps:

Import the NudgeCore package into your Dart file:

import 'package:nudge_core/nudge_core.dart';

Create an instance of the NudgeCore class with your desired variable name and add:

  • token (required): The secret key obtained from the Nudge website, used for authentication.
 final core = NudgeCore(<TOKEN>);

Nudge Provider #

The NudgeProvider is a Flutter widget that should be wrapped around the main MaterialApp widget in your application. It enables integration with the Nudge package and requires two parameters: nudgeInstance and child.

Parameters #

  • app (required): An instance of the Nudge core initialized with your unique token. The Nudge core manages your application's integration with the Nudge platform.

  • child (required): The child widget, typically the MaterialApp widget, that will be rendered below the NudgeProvider. It should include the navigatorKey parameter.
    Example

  return NudgeProvider(
      nudgeInstance: core,
      child: MaterialApp(
        navigatorKey: NudgeProviderState.navigatorKey,
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: Home(),
      ),
    );

Initializing session #

Whenever a distinct user Id which is used to identify users at the client's end is defined, call the initSession function to initialize the user session.

  await core.initSession(externalId:'CLIENT_IDENTIFIABLE_USER_ID');

You can also send more user attributes along with the user ID for making segments of audiences.

  await core.initSession('CLIENT_IDENTIFIABLE_USER_ID',
                  properties: <String, dynamic>{
                  "name": "Client User 1",
                  "age": 27,
                  "gender": "M",
                  "country":"US",
                  });

Start Tracking Events #

Make shure you have initialized sesstion before tracking
To track an event, simply call

await core.track(type:'EVENT_TYPE');

You can also add event properties for analytics and .making segments of users based on the properties of their events performed for custom audience experiences.

await core.track(type:'EVENT_TYPE',
                  properties: <String, dynamic>{
                  "product": "Fortune Cookies",
                  "quantity": 5,
                  "countryOfExport":"US",
                  });
2
likes
120
points
437
downloads

Publisher

unverified uploader

Weekly Downloads

The Official core package to enable Nudge tracking and in-app experiences in your Flutter app by Nudge (www.nudgenow.com).

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, http_parser, uni_links, uuid

More

Packages that depend on nudge_core