flutter_1flow_sdk 2023.6.23 copy "flutter_1flow_sdk: ^2023.6.23" to clipboard
flutter_1flow_sdk: ^2023.6.23 copied to clipboard

outdated

1Flow flutter SDK.

example/lib/main.dart

import 'dart:developer';

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

import 'package:flutter/services.dart';
import 'package:flutter_1flow_sdk/flutter_1flow_sdk.dart';

void main() {
  runApp(MyApp());
  String projectKey = "";
  OneFlow.configure(projectKey);
  OneFlow.logUser('fluttersdk_2023.6.20',{ 'tested_by': 'Amit Sanvedi' });
  OneFlow.getSDKVersion().then((version) {
  print("version:" + version);
});

//  OneFlow.logUser('fluttersdk_2023.6.20',{ 'tested_by': 'Amit Sanvedi' });
 // OneFlow.useFont(fontFamily: "Courier New"); //For iOS Only
  //OneFlow.useFont(path: "fonts/pacifico.ttf"); // For Android Only
  //OneFlow.useFont(fontFamily: "Courier New", path: "fonts/pacifico.ttf"); // For iOS & Android Both
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

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

    OneFlow.methodchannel.setMethodCallHandler(oneFlowSurveyFinishNotificationHandler);

    initPlatformState();
  }

Future<void> oneFlowSurveyFinishNotificationHandler(MethodCall call) async {
      final String method = call.method;
      dynamic argument = call.arguments;
                  print("oneFlowSurveyFinishNotificationHandler"); 
      switch(method) { 
          case "oneFlowSurveyFinishNotification": {  
            print("oneFlowSurveyFinishNotification: $argument");
          } 
          break; 
          default: { 
            print("Invalid choice"); 
          } 
          break; 
      } 
}
   void recordEvent(){
   try {
        OneFlow.recordEventName('session_start', null);
        print('recordEventName: Done');
      } on PlatformException {
      print('recordEventName: error occured');
    }
      }
 void startFlow(){
   try {
        OneFlow.startFlow('298222a3ffc2e177690c1e30');
        print('startFlow: Done');
      } on PlatformException {
      print('startFlow: error occured');
    }
      }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    
    if (!mounted) return;

    setState(() {

    });
  }

  @override
  Widget build(BuildContext context) {
return MaterialApp(
    title: 'Tittle',
    home: Scaffold(
      body: Column(
  mainAxisAlignment: MainAxisAlignment.center,
  crossAxisAlignment: CrossAxisAlignment.center,children: [
        new TextButton(onPressed: () {recordEvent();}, child: Text("Record Event")),
        SizedBox(width: 150),
        new TextButton(onPressed: () {startFlow();}, child: Text("Start Flow"))
      ]),
    ));
}
}
3
likes
0
points
611
downloads

Publisher

verified publisher1flow.app

Weekly Downloads

1Flow flutter SDK.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_1flow_sdk