Skip to main content
Version: 4.6.1-saas

Quick Start

Get started with NetFUNNEL 4 Flutter Agent in 5-10 minutes with this quick start guide.

What You Can Do in This Guide

  • Code-based integration: Control traffic with precise timing at the button/API level
Choosing an Integration Method

To compare integration methods and find the most suitable approach for your use case, refer to the Integration Methods Overview.


Prerequisites

  • NetFUNNEL console access
  • Flutter project
  • Basic Dart knowledge
Sample Projects

Need a basic project for practice? Check out the Sample Projects.


Step 1: Get Client ID

  1. Go to the NetFUNNEL console
  2. Click the profile icon in the top right
  3. Select the Integration Credentials menu
  4. Copy the Client ID

Step 2: Installation and Initialization

Package Installation

After copying the tar.gz file to the project root or your desired location, add the dependency to pubspec.yaml:

dependencies:
netfunnel_flutter:
path: ./netfunnel_flutter-{{latest}} # Path where tar.gz file is copied

Run the following command in the terminal:

flutter pub get

Network Permission Configuration

For Android, add internet permission to android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- Internet permission configuration -->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

Initialization

Perform the initialization in the main() function of main.dart:

import 'package:netfunnel_flutter/netfunnel_flutter.dart';

void main() async {
// NetFUNNEL agent initialization
await Netfunnel.instance.initialize(
clientId: 'your-client-id', // Client ID obtained in Step 1
);
runApp(MyApp());
}

Step 3: Choose Integration Method

Basic Control

Best for: Button clicks, API calls, single-step operations

  1. Create a segment in the console:

    • Go to ProjectsSegmentCreate Segment
    • Select Basic Control
    • Set Entry Allowance to 0 (for testing)
  2. Add to code:

import 'package:netfunnel_flutter/netfunnel_flutter.dart';

class NetfunnelHandler extends NetfunnelCallback {
@override
void onSuccess(int statusCode, String message) {
// When entry or bypass response is received
// Execute existing service logic
}

@override
void onError(int statusCode, String message) {
// When system error occurs
// Generally handled the same as onSuccess
}

@override
void onNetworkError(int statusCode, String message) {
// When network error occurs
// Handle retry or notification
}

@override
void onBlock(int statusCode, String message) {
// Logic to handle when user entry is blocked
}

@override
void onClose(int statusCode, String message) {
// Logic to handle when user cancels waiting
}
}

// On button click
void handleButtonPress(BuildContext context) {
Netfunnel.instance.nfStart(
projectKey: '{{PROJECT_KEY}}', // Project key from console
segmentKey: '{{SEGMENT_KEY}}', // Segment key from console
callback: NetfunnelHandler(),
context: context,
);
}

// Return key after action completion
void handleActionComplete() {
Netfunnel.instance.nfStop(
projectKey: '{{PROJECT_KEY}}',
segmentKey: '{{SEGMENT_KEY}}',
);
}

Section Control

Best for: Payment processes, multi-step processes

  1. Create a segment in the console (same as basic control)
  2. Add to code:
// Start section
Netfunnel.instance.nfStartSection(
projectKey: '{{PROJECT_KEY}}',
segmentKey: '{{SEGMENT_KEY}}',
callback: NetfunnelHandler(),
context: context,
);

// End section (when entire process is complete)
Netfunnel.instance.nfStopSection(
projectKey: '{{PROJECT_KEY}}',
segmentKey: '{{SEGMENT_KEY}}',
);

Step 4: Testing

  1. Set entry allowance to 0 and verify that the waiting room is displayed correctly
  2. Set entry allowance to 1 (should enter immediately)
  3. Verify key return in Network tab (ts.wseq?opcode=5004 HTTP 200)

Need Help?

  • Troubleshooting: Common issues and solutions
  • Check NetFUNNEL logs in Flutter console (set printLog: true)
  • Verify that project/segment keys from console match exactly