Installation and Initialization
This guide explains the installation and initialization process for the NetFUNNEL Flutter agent.
Step 1: Package Installation
Adding Dependencies
The NetFUNNEL Flutter agent is provided as a tar.gz package file. It is not available through public repositories (pub.dev), so you must add the provided archive file directly to your project.
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
The pubspec.yaml file recognizes hierarchical structure based on indentation, so be careful with indentation.
Installing the Package
Run the following command from the project root directory:
flutter pub get
Step 2: Network Permission Configuration
Android
For Android, you need to add internet usage permission to communicate with the NetFUNNEL server.
Add the following permission to the android/app/src/main/AndroidManifest.xml file:
<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>
iOS
iOS has internet permission enabled by default. No additional configuration is required.
Step 3: Getting Client ID
- Go to the NetFUNNEL console
- Click the profile icon in the top right
- Select the
Integration Credentialsmenu - Copy the
Client ID
You can find it in the Integration Credentials menu after clicking the profile icon in the top right of the console screen.
Step 4: Agent Initialization
The NetFUNNEL Flutter agent must be initialized when the app starts.
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: '{{CLIENT_ID}}', // Client ID obtained in Step 3
serverUrl: '{{SERVER_URL}}', // Optional
errorUrl: '{{ERROR_URL}}', // Optional
networkTimeout: 3000,
retryCount: 0,
printLog: false,
errorBypass: false,
useNetfunnelTemplate: true,
userId: '{{USER_ID}}', // Optional
useNetworkRecoveryMode: true,
profile: 'prod_tokyo',
);
runApp(MyApp());
}
Initialization Parameters
| Parameter | Type | Description | Conditions |
|---|---|---|---|
clientId | String | User unique identifier | Cannot be empty string |
serverUrl | String | NetFUNNEL server address | None (uses default address) |
errorUrl | String | HTML address of NetFUNNEL error page | None (uses default address) |
networkTimeout | int | Maximum time to wait for network response | Default (ms): 3,000 Maximum (ms): 10,000 Minimum (ms): 100 |
retryCount | int | Number of retries on network request failure | Default (times): 0 Maximum (times): 10 Minimum (times): 0 |
printLog | bool | Whether to output logs for debugging | Default: false |
errorBypass | bool | Whether to bypass on error | Default: false |
useNetfunnelTemplate | bool | Whether to use NetFUNNEL waiting room customized in console | Default: true |
userId | String | Unique identifier of end-user for blacklist and whitelist checking | Default: null |
useNetworkRecoveryMode | bool | Whether to use feature that maintains waiting room and attempts reconnection when network connection is lost | Default: false |
profile | String | User environment configuration (prod_tokyo, prod_us_east) | Default: prod_tokyo |
For detailed information on all initialization parameters, refer to the Initialization Options documentation.
Step 5: Installation Verification
To verify that the agent is installed correctly, check the following:
- Initialization Success: No errors should occur when the app starts
- Log Verification: If
printLog: trueis set, you can check logs with the[NF4]prefix in the Flutter console
Troubleshooting
Package Installation Failure:
- Check network connection
- Verify dependency path in
pubspec.yaml - Verify that the tar.gz file is in the correct location
Initialization Failure:
- Verify that
clientIdis set correctly - Verify that it is not an empty string
Next Steps
- Quick Start: Get started with basic examples
- Integration Methods: Comparison of basic control and section control
- API Reference: Complete function specifications