instadiv 0.0.2 copy "instadiv: ^0.0.2" to clipboard
instadiv: ^0.0.2 copied to clipboard

outdated

InstaDiv is a SaaS which helps in boosting in-app engagment using server-driven pop-ups, Picture-in-Picture stories, banners & carousels. This package serves as client side SDK for apps developed usin [...]

example/lib/main.dart

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:instadiv/instadiv.dart';
import 'package:instadiv/widget/insta_view.dart';
import 'package:instadiv/widget/pip/insta_screen.dart';
import 'package:instadiv_example/env.dart';
import 'package:instadiv_example/second_screen.dart';

import 'firebase_options.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  bool _initialized = false;

  @override
  void initState() {
    super.initState();
    initFirebase();
  }

  Future<void> initFirebase() async {
    if (!mounted) return;

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

    final instadivPlugin = Instadiv.getInstance();
    instadivPlugin.setFirebase(Firebase.app());
    instadivPlugin.setCred(apiKey, projectId);

    setState(() {
      _initialized = true;
    });
  }

  @override
  Widget build(BuildContext context) {

    if (!_initialized) {
      return MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Scaffold(
              body: Container(
        color: Colors.white,
        child: const Center(
          child: CircularProgressIndicator.adaptive(),
        ),
      )));
    }
    return const InstaScreenWidget(appWidget: HomePage());
  }
}

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

  @override
  Widget build(BuildContext context) {

    final instadivPlugin = Instadiv.getInstance();

    // Set onPress for 'OK' action of inapp dialog
    // If not set it will open the link
    instadivPlugin.setInAppCTA((url) {
      print(url);
      Navigator.of(context)
          .push(MaterialPageRoute(builder: (context) => const SecondScreen()));
    });

    // Set onPress for 'Story view CTA
    // If not set it will open the link
    instadivPlugin.setStoryViewCTA((url) {
      print(url);
      Navigator.of(context)
          .push(MaterialPageRoute(builder: (context) => const SecondScreen()));
    });

    return Scaffold(
      appBar: AppBar(
        title: const Text('InstaDiv Sample'),
      ),
      body: getViewsFromClientFirebase(context),
    );
  }

  Widget getViewsFromClientFirebase(BuildContext context){
    return Column(children: [
      const SizedBox(height: 16),
      InstaView(
          viewId: 'fZ69czXvqNiZz4488gDI',
          onPress: (uri) => Instadiv.getInstance()
              .logEvent(context, 'event_name', 'logged_in')),
      const InstaView(
          viewId: 'KMlgfgXisxDJGdJtcJKr'),
    ]);
  }

}
1
likes
0
points
15
downloads

Publisher

verified publisherinstadiv.com

Weekly Downloads

InstaDiv is a SaaS which helps in boosting in-app engagment using server-driven pop-ups, Picture-in-Picture stories, banners & carousels. This package serves as client side SDK for apps developed using flutter.

Homepage

License

unknown (license)

Dependencies

carousel_slider, cloud_firestore, collection, equatable, firebase_core, flutter, flutter_bloc, flutter_cache_manager, giffy_dialog, http, pip_view, plugin_platform_interface, rxdart, shared_preferences, url_launcher, video_player

More

Packages that depend on instadiv