gleap_sdk 7.0.0 copy "gleap_sdk: ^7.0.0" to clipboard
gleap_sdk: ^7.0.0 copied to clipboard

The Gleap SDK for Flutter is the easiest way to integrate Gleap into your apps!

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:gleap_sdk/gleap_sdk.dart';
import 'package:gleap_sdk/models/gleap_user_property_model/gleap_user_property_model.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    await Gleap.enableDebugConsoleLog();
    await Gleap.initialize(
      token: 'API_KEY',
    );

    Gleap.preFillForm(formData: <String, dynamic>{
      'bugdescription': 'While I was trying to do something, I found a bug.',
    });

    Gleap.registerListener(
      actionName: 'custom-action',
      callbackHandler: (dynamic action) {
        print(action);
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Gleap Example'),
          backgroundColor: const Color(0xFF485BFF),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              GestureDetector(
                onTap: () async {
                  await Gleap.identify(
                    userId: "123456",
                    userProperties: GleapUserProperty(
                      name: 'Franz',
                      email: 'franz@gleap.io',
                    ),
                    userHash:
                        "e12817b1f1xedb72381b249eb22ecd0dc1c4s0bb15188b5485d441485347y26f",
                  );
                },
                child: Container(
                  alignment: Alignment.center,
                  height: 50,
                  width: 150,
                  color: const Color(0xFF485BFF),
                  child: const Text(
                    'Identify',
                    style: TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
              ),
              const SizedBox(
                height: 20.0,
              ),
              GestureDetector(
                onTap: () async {
                  await Gleap.clearIdentity();
                },
                child: Container(
                  alignment: Alignment.center,
                  height: 50,
                  width: 150,
                  color: const Color(0xFF485BFF),
                  child: const Text(
                    'Clear identity',
                    style: TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
              ),
              const SizedBox(
                height: 20.0,
              ),
              GestureDetector(
                onTap: () async {
                  Gleap.sendSilentCrashReport(
                    description: 'Silent crash report',
                    severity: Severity.HIGH,
                  );
                },
                child: Container(
                  alignment: Alignment.center,
                  height: 50,
                  width: 150,
                  color: const Color(0xFF485BFF),
                  child: const Text(
                    'Silent crash report',
                    style: TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
12
likes
0
pub points
87%
popularity

Publisher

verified publishergleap.io

The Gleap SDK for Flutter is the easiest way to integrate Gleap into your apps!

Homepage

License

unknown (LICENSE)

Dependencies

flutter, flutter_web_plugins, js, json_annotation

More

Packages that depend on gleap_sdk