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
- Go to the NetFUNNEL console
- Click the profile icon in the top right
- Select the
Integration Credentialsmenu - 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
-
Create a segment in the console:
- Go to
Projects→Segment→Create Segment - Select Basic Control
- Set
Entry Allowanceto0(for testing)
- Go to
-
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
- Create a segment in the console (same as basic control)
- 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
- Set entry allowance to 0 and verify that the waiting room is displayed correctly
- Set entry allowance to 1 (should enter immediately)
- Verify key return in Network tab (
ts.wseq?opcode=5004HTTP 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