Flutter Import Cost Calculator
A Visual Studio Code extension that shows the size impact of imported packages in Flutter/Dart projects.
Features
- Displays the size of imported Flutter packages directly in your editor
- Shows both raw and gzipped sizes of packages
- Caches results to minimize API calls and improve performance
- Highlights large packages that may impact your app size
- Works with both direct and transitive dependencies

How It Works
This extension:
- Detects import statements in your Flutter/Dart files
- Calculates the size impact of each imported package
- Shows the size information inline in your editor
- Highlights packages that exceed configured size thresholds
The extension uses two methods to calculate package sizes:
- API Mode (default): Uses the pub.dev API to get package information and estimates sizes based on available data
- Download Mode: Downloads and analyzes packages to get actual size information (more accurate but slower)
Requirements
- Visual Studio Code 1.70.0 or newer
- For Download Mode: Dart SDK installed and available in PATH
Extension Settings
This extension contributes the following settings:
flutterImportCost.enabled : Enable/disable the Flutter Import Cost Calculator
flutterImportCost.showInStatusBar : Show total import cost in status bar
flutterImportCost.sizeCutoff : Size in KB above which to highlight large packages
flutterImportCost.useActualDownload : Download and analyze packages instead of using API estimates (more accurate but slower)
Installation
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "Flutter Cost"
- Click Install
Usage
- Open any Dart file in a Flutter project
- The extension will automatically analyze import statements and display size information
- Hover over the size information to see additional details
- Use the command "Calculate Flutter Import Costs" to manually refresh calculations
Development
If you want to contribute to this extension:
- Clone the repository
- Run
npm install
- Open the project in VS Code and press F5 to launch extension development host
- Make changes and test them in the development host window
Building From Source
# Clone the repository
git clone https://github.com/antaerio/FlutterCost.git
cd flutter-cost
# Install dependencies
npm install
# Compile the extension
npm run compile
# Package the extension
npx vsce package
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Known Issues
- Size calculations are estimates and may not perfectly match the actual impact on app size
- Transitive dependencies may not be fully accounted for in API Mode
- Packages with platform-specific implementations may show different sizes than what's used in your actual build
Release Notes
0.1.0
- Initial release
- Basic import cost calculation
- Inline display of package sizes
- Caching system for performance
| |