搜尋套件、儲存庫與 APP 分類

logarte 封面
套件詳情v1.5.0

logarte

功能強大的 Flutter 應用內調試控制台,具備網路檢查器、儲存監控和密碼保護功能

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
6880
喜歡數
249
Pub 分數
120

安裝套件

flutter pub add logarte

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Logarte 是一個功能完整的 Flutter 應用內調試控制台,提供即時記錄、網路檢視、儲存空間監控,以及密碼保護存取,以保護敏感資料。專為開發者設計,提供直覺介面,可在 Android、iOS、Web、macOS、Windows 和 Linux 等多個平台追蹤應用行為,用於開發與測試。此套件透過將關鍵工具整合至單一安全介面,提升除錯效率,讓診斷問題更輕鬆,無需完全依賴終端機日誌。

適用情境

  • Flutter 應用的即時除錯
  • 監控網路請求和回應
  • 檢查本機儲存和共用偏好設定
  • 使用密碼保護來確保調試工具的安全
  • 在多個平台上測試應用程式行為

主要特色

  • 具豐富 UI 的應用內除錯主控台
  • 網路請求檢查器
  • 本機資料儲存監控
  • 密碼保護存取
  • 跨平台支援(Android、iOS、Web、macOS、Windows、Linux)

適合對象

  • Flutter 開發者在積極開發中
  • 需要安全調試訪問的團隊
  • 需要詳細執行時診斷的應用程式
  • 涉及敏感數據處理的項目
  • 除錯複雜的狀態或網路問題

使用建議

  • 不適用於生產發行
  • 在除錯模式下需要手動啟用
  • 可能稍微增加應用大小
  • 密碼必須在執行時設定
  • 限於開發和測試環境

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

logarte

In-app debug console and logger for Flutter apps.

📦 Features

  • 🚀 In-app console: Monitor your app inside your app
  • 🔒 Access control: Optional password protection
  • 📡 Network inspector: Track API calls and responses
  • 📁 Storage monitor: Track local storage operations
  • 📤 Copy & export: Share debug logs with your team
  • 📄 Curl command: Copy cURL command for API requests

📱 Screenshots

Console API Request Password

🩵 Sponsors

Want to say "thanks"? Check out our sponsors:

🪚 Usage

Add to pubspec.yaml
dependencies:
  logarte: ^0.2.1

Then run flutter pub get.

Initialize

Create a global Logarte instance:

final Logarte logarte = Logarte(
    // Protect with password
    password: '1234',
    
    // Skip password in debug mode
    ignorePassword: kDebugMode,

    // Share network request
    onShare: (String content) {
      Share.share(content);
    },

    // To have logs in IDE's debug console (default is false)
    disableDebugConsoleLogs: false,

    // Add shortcut actions (optional)
    onRocketLongPressed: (context) {
      // e.g: toggle theme mode
    }
    onRocketDoubleTapped: (context) {
      // e.g: change language
    }
);
Enable the debug console
In debug mode

Ideally, you should attach the floating button to the widget tree, then click it to open the debug console. This is the preferred way because you don't know when you'll need it and sometimes you might need to go back and forth many times. So, it's better to have it on the UI always.

@override
void initState() {
  super.initState();
  
  logarte.attach(
    context: context,
    visible: kDebugMode,
  );
}

This will attach the floating button when in debug mode. Curious how you can access it in production when it's not debug mode? Check below.

In production

Logarte is as valuable in production mode as it is in debug mode. Whenever you find a bug, notice something not working, API requests failing, etc., you should be able to check the console and find why.

Two ways to access in production:

Hidden gesture trigger

LogarteMagicalTap is a widget that attaches the floating button to the UI when tapped 10 times. Wrap any non-tappable widget, keep it secret, and make sure you've set a password while initializing.

LogarteMagicalTap(
  logarte: logarte,
  child: Text('App Version 1.0'),
)
Manual trigger

You might also have creative ideas on when and how to open the console. For example, I used a shake detection plugin and attached the floating button when the device was shaken 3 times consecutively. From my experience, this is extremely valuable. Why? Imagine: you've opened your app, went to deeper screens, and an API call failed. You say 'Thank God I've already integrated logarte. Let's open that console!' But you need to go to the page where you used LogarteMagicalTap, which might be too far or not visible at that stage of the app - maybe you're showing it on the profile page and you are on the login page. So be creative about where to add it and consider using shake detection or anything that would serve you better.

logarte.openConsole(context);

Different from the .attach(context) method, this will directly open the console (password page if set, else the console itself).

Log network requests
With Dio
dio.interceptors.add(LogarteDioInterceptor(logarte));

That's it? Yes, that's it. Now, all the network requests will be logged in both the debug and the graphical console.

With other HTTP clients
// After your HTTP request:
logarte.network(
  request: NetworkRequestLogarteEntry(
    method: 'POST',
    url: endpoint,
    headers: headers,
    body: body,
  ),
  response: NetworkResponseLogarteEntry(
    statusCode: response.statusCode,
    headers: response.headers,
    body: response.body,
  ),
);
Log messages
logarte.log('Button clicked');

This will log messages in both your IDE's debug console and the in-app logarte console.

Track navigation
MaterialApp(
  navigatorObservers: [LogarteNavigatorObserver(logarte)],
)
Track storage operations
logarte.database(
  target: 'language',
  value: 'en',
  source: 'SharedPreferences',
);
Add custom debug tab

While initializing, you can pass a custom tab widget to the Logarte instance. This tab will be shown in the console.

This is useful when you want to add a custom tab to the console, for example, to change the environment, copy device's FCM token, clear local cache, etc.

final Logarte logarte = Logarte(
  ...
  customTab: const MyCustomTab(),
  ...
);

🕹️ Example

See the complete example in this repository.

📄 License

MIT License - see LICENSE.

所屬分類

依賴

依賴清單 1 項

  • dio>=4.0.0 <6.0.0

原始碼儲存庫

使用此套件的專案