import_ozempic đ
Trim the fat from your Dart imports.
Is your codebase carrying extra weight from bloated import statements? Time for a transformation! import_ozempic helps your Dart projects shed those unused imports and get lean, organized, and healthy.
â ď¸ Disclaimer: These statements have not been evaluated by the FDA. This tool is not intended to diagnose, treat, cure, or prevent any diseases in your codebase. Results may vary. Consult your tech lead before starting any new import regimen.
Features
- Automatic Import Organization: Get your imports in shape! Groups imports into three categories in the correct order:
- Dart core libraries (
dart:*) - Package imports (
package:*) - Relative imports
- Dart core libraries (
- Unused Import Removal: Cuts out the excessâdetects and removes unused imports that are just adding bulk
- Multi-file Processing: Process individual files, multiple files, or give your entire directory a complete makeover
- Configurable Exclusions: Some files are already perfect (like generated files)âexclude what you want to keep as-is
- Part File Support: Correctly handles Dart libraries with part filesâno side effects!
Installation
Ready to start your import weight-loss journey?
Add import_ozempic to your pubspec.yaml:
dev_dependencies:
import_ozempic: <version>
Or activate it globally for quick access:
dart pub global activate import_ozempic
Usage
Basic Usage
Give a single file a quick checkup:
import_ozempic fix lib/main.dart
if you installed it as a dependency, you can run it with
dart run import_ozempic fix lib/main.dart
Or use the shorter ioz alias (because who has time for long commands?):
ioz fix lib/main.dart
Treat multiple files at once:
import_ozempic fix lib/main.dart lib/utils.dart
Go for the full transformationâfix an entire directory:
import_ozempic fix .
With Configuration
Want a personalized treatment plan? Create a configuration file (e.g., import_cleaner.yaml):
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "**/generated/**"
Then run with the config:
import_ozempic fix . --config import_cleaner.yaml
Configuration
The configuration file supports the following options:
exclude
A list of file paths or glob patterns to exclude from processing. Think of these as the files that are already at their ideal weight!
Example:
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "lib/generated/**"
- "test/fixtures/**"
format
A boolean flag to control import formatting. When false (default), each import statement remains on a single line. When true, imports are formatted according to Dart's style guideâfor when you want that extra polish!
Example:
format: true
exclude:
- "**/*.g.dart"
How It Works
The secret formula for healthy imports:
- Analysis: Uses Dart's analyzer to examine your code (the medical checkup)
- Reference Collection: Traverses the AST to collect all type references (checking vital signs)
- Import Resolution: Determines which imports are actually needed (diagnosis)
- Organization: Rewrites import statements in the correct order with proper grouping (the treatment)
- Cleanup: Runs
dart fixto remove unused imports and fix related warnings (follow-up care)
Example
Before: Carrying excess baggage đ
import 'dart:async';
import 'package:project_domain/domain.dart' hide DateFormat;
import 'package:flutter/material.dart' hide Divider, IconButton;
import 'package:flutter/services.dart' hide TextInput;
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:formz/formz.dart';
import 'package:provider/provider.dart';
import 'package:select_when/select_when.dart';
After: Lean, precise, and organized đŞ
import 'dart:async' show Completer;
import 'package:project_domain/enums/user_type.dart' show UserType;
import 'package:flutter/src/foundation/key.dart' show Key, ValueKey;
import 'package:flutter/src/painting/edge_insets.dart' show EdgeInsets;
import 'package:flutter/src/widgets/basic.dart' show Builder, Column, Expanded, KeyedSubtree, SizedBox;
import 'package:flutter/src/widgets/framework.dart' show BuildContext, State, StatefulWidget, StatelessWidget, Widget;
import 'package:flutter_bloc/src/bloc_provider.dart' show BlocProvider;
import 'package:formz/formz.dart' show FormzInput, FormzMixin;
import 'package:provider/src/change_notifier_provider.dart' show ChangeNotifierProvider;
import 'package:provider/src/provider.dart' show MultiProvider, Provider, ReadContext, SelectContext;
import 'package:select_when/src/select_when_context.dart' show SelectWhenContext;
Notice how we've eliminated the unnecessary bloat and only import exactly what you need. Your imports just got a lot healthier!
Requirements
- Dart SDK:
>=3.8.0 <4.0.0
Development
We use sip_cli to manage project scripts. The scripts are defined in the scripts.yaml file.
Running Tests
sip test
Installing Locally
sip run install
License
MIT
Contributing
Got ideas to make import_ozempic even more effective? Contributions are welcome! Help us trim even more fat from Dart codebasesâsubmit a Pull Request and join the wellness movement! đââď¸
Libraries
- commands/fix_command
- commands/restore_command
- commands/update_command
- deps/analyzer
- deps/args
- deps/find
- deps/fs
- deps/is_up_to_date
- deps/log
- deps/platform
- deps/process
- deps/pub_updater
- domain/analysis_options
- domain/analyzer
- domain/args
- domain/combinator
- domain/config
- domain/find
- domain/import
- domain/import_type_collector
- domain/is_up_to_date
- domain/multi_reference
- domain/process_details
- domain/reference
- domain/resolved_import
- domain/resolved_references
- domain/units
- gen/pkg
- gen/version
- import_ozempic