搜索插件、代码仓与 APP 分类

插件详情v0.5.2

flutter_stetho

适用于 Android 上 Flutter 的 Chrome DevTools 网络检查器

近 30 天下载
607
喜欢数
42
Pub 分数
35

安装插件

flutter pub add flutter_stetho

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

flutter_stetho 是一个调试工具,可将 Chrome DevTools 与 Android 上的 Flutter 集成,使开发者能够实时检查网络请求和响应。它利用 Facebook 的 Stetho 库,提供对 HTTP 流量的详细洞察,包括请求头、负载和时间信息。该包通过提供一个熟悉的界面来诊断网络相关问题,从而增强开发工作流程,且无需额外设置,只需添加依赖项即可。在应用开发和测试阶段尤其有用。

适合场景

  • 检查 HTTP 请求和响应
  • 调试 API 集成
  • 监控网络性能
  • 排查连接问题
  • 实时网络日志

主要特点

  • Chrome DevTools 集成
  • 网络请求检查
  • 实时交通监控
  • 通过 pub add 进行简单设置
  • 仅限 Android 支持

适合对象

  • Flutter 开发人员调试网络调用
  • 使用 Chrome DevTools 工作流的团队
  • 专注于API行为的移动应用测试人员

使用建议

  • 仅限 Android 平台
  • 不适用于生产构建
  • 需要 Chrome DevTools
  • 可能会影响调试模式下的性能
  • 无 iOS 支持

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

flutter_stetho

A plugin that connects Flutter to the Chrome Dev Tools on Android devices via the Stetho Android Library.

Network Inspector

The main feature I was aiming to achieve was a Network Inspector.

Network Inspector in Action

Getting Started

How can you too get this plugin up and running in your own app? Follow these steps.

Install the plugin

Add flutter_stetho to your dependencies in the pubspec.yaml file

  • For Flutter 1.7.x, use version 0.3.x
  • For Flutter 1.8.x, use version 0.4.x
  • For Flutter 1.9.x, use version 0.5.x
Install StethoHttpOverrides

Next, you'll need to install the Stetho.initialize() in the main() function of your app. This will enable Stetho and allow flutter_stetho to wrap all http calls and report information to the Chrome Dev Tools via the Stetho package from Facebook.

Note: It's probably a good idea only put this override in a main_dev.dart file.

void main() {
  Stetho.initialize();

  runApp(new MyApp());
}
Run your app on an Android Device

flutter run

Open Chrome

Pop open Chrome or Chromium, navigate to chrome://inspect

You should now see your App appear in the window.

Known Issues

  • Timing may be slightly off for some requests. That's because:
  • Code is rough mvp / prototype code. Needs improvement.
  • Animated Gifs not working
  • Some error cases may not be properly handled. Need more testing / feedback to find problems.
  • No Tests
  • If the app shuts down on start up run flutter clean to remove old builds.

所属分类

源码仓库

使用此插件的项目