How to Use Flutter Flipper Kit for Mobile App Debugging

Feb 26, 2022 | Programming

The world of mobile app debugging often feels like venturing into an uncharted jungle. Fortunately, the Flutter Flipper Kit serves as a reliable compass, guiding developers through the dense foliage of code errors and performance issues. In this article, we’ll explore how to get started with this essential tool for Flutter apps.

Introduction

Flutter Flipper Kit is an extensible mobile app debugger specifically designed for Flutter applications. It integrates seamlessly with the Flipper Desktop, offering a suite of features that helps with debugging.

Features

  • Network Inspector
  • Shared Preferences Inspector
  • Redux Inspector
  • Database Browser

Quick Start

Prerequisites

Before diving in, ensure you have the following:

Installation

To install Flutter Flipper Kit, you need to add it to your project’s pubspec.yaml file:

dependencies:
  flutter_flipperkit: ^0.0.29
# or use the git repository directly
dependencies:
  flutter_flipperkit:
    git:
      url: https://github.com/leanflutter/flutter_flipperkit
      ref: main

Android Setup

Tailor your project files according to the example provided:

android/settings.gradle:
include ':app'

def localPropertiesFile = new File(rootProject.projectDir, 'local.properties')
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader('UTF-8') { reader ->
    properties.load(reader)
}
def flutterSdkPath = properties.getProperty('flutter.sdk')
assert flutterSdkPath != null, 'flutter.sdk not set in local.properties'

apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

iOS Setup

Open ios/Runner.xcworkspace and add an empty Swift file (e.g., Runner-Noop.swift) into the Runner Group. Ensure that the Runner-Bridging-Header.h file is created. Adjust your project ios/Podfile according to the example:

platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
    Debug    => :debug,
    Profile  => :release,
    Release  => :release,
}

# Further settings...

Usage

To start utilizing Flutter Flipper Kit in your app, you need to import the package and initialize the Flipper client:

import 'package:flutter_flipperkit/flutter_flipperkit.dart';

void main() {
    FlipperClient flipperClient = FlipperClient.getDefault();

    flipperClient.addPlugin(new FlipperNetworkPlugin(
        useHttpOverrides: false,
        filter: (HttpClientRequest request) {
            String url = request.uri.toString();
            return !(url.startsWith('https://via.placeholder.com') || url.startsWith('https://gravatar.com'));
        }
    ));
    
    flipperClient.addPlugin(new FlipperReduxInspectorPlugin());
    flipperClient.addPlugin(new FlipperSharedPreferencesPlugin());
    flipperClient.start();

    runApp(MyApp());
}

For practical examples and further integration details, refer to the examples repository.

Run the App

Finally, to execute your application, use the following command:

bash
$ flutter run

Related Links

Discussion

If you have suggestions or inquiries regarding this project, feel free to join the discussion at the Telegram Group.

Troubleshooting

Should you encounter any installation issues or performance bugs, here are some tips to keep in mind:

  • Ensure that you have the necessary permissions set up for both Android and iOS.
  • Double-check the SDK paths and ensure Flutter SDK is properly configured.
  • If you’re facing network-related issues, verify the filter methods you’ve applied.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

License

This project is licensed under the MIT License. You can freely use, modify, and distribute the software as per the terms specified.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox