EazyFlutter is a powerful VS Code extension designed to streamline Flutter development by offering quick actions, intelligent widget wrappers, and useful snippets. This extension simplifies common tasks such as wrapping widgets with Consumer<T>, generating getter and setter methods, and converting JSON data into Dart models using json_serializable.
EazyFlutter makes it easy to manage your Flutter localization workflow:
- Select a String: Highlight any string literal in your Dart code that you want to localize.
- Trigger the Quick Fix: Press Cmd+. (Mac) or Ctrl+. (Windows/Linux) to open the light bulb menu, then select "Add to .arb localization files".
- Automatic Key Generation: The extension generates a camelCase key from your string (e.g.,
"This is a sample"→thisIsASample). - .arb File Management:
- If English .arb file(s) exist (e.g.,
app_en.arb,english.arb,en.arb), the key and value are added there:
"thisIsASample": "This is a sample" - In other .arb files, the key is added with an empty value:
"thisIsASample": "" - If no .arb files exist, a
lib/l10n/app_en.arbfile is created automatically.
- If English .arb file(s) exist (e.g.,
- Code Replacement: The selected string in your Dart code is replaced with the generated key, optionally prefixed (see below).
- l10n Generation (Optional): If enabled, the extension will automatically run the correct localization generation command after updating .arb files (see below).
Suppose you have this code:
Text('You have reached your contact view limit')After using the Quick Fix, your app_en.arb will have:
{
"youHaveReachedYourContactViewLimit": "You have reached your contact view limit"
}And your Dart code will be updated to:
Text(AppLocalizations.of(context).youHaveReachedYourContactViewLimit)(Prefix is configurable, see below)
-
Localization Key Prefix: In VS Code settings, search for
EazyFlutter: Localization Key Prefix. Set this to the prefix you want before the key in your code (e.g.,AppLocalizations.of(context).orLocalizations.locale.). Leave blank for just the key. -
Auto L10n Generate: Enable
EazyFlutter: Auto L10n Generateto automatically run the correct localization generation command after .arb updates:- If your project uses FVM (detected by a
fvmor.fvmdirectory), the extension runs:fvm flutter gen-l10n
- Otherwise, it runs:
flutter gen-l10n
- The command is executed in a new VS Code terminal named "EazyFlutter l10n".
- If your project uses FVM (detected by a
- No more manual .arb editing: Add and sync translations with a single action.
- Consistent key naming: Keys are generated in camelCase from your strings.
- Flexible code integration: Use any localization prefix pattern your project requires.
- Automated l10n workflow: Keep your generated Dart localization files up to date with zero hassle.
- JSON to Dart Conversion - Convert JSON input into a structured Dart model with
json_serializable, automatically saving it in the model folder (You can move it to your desired directory after). - Wrap with Consumer - A quick action is available that wraps widgets with a
Consumerfor Provider-based state management.
- Wrap with Consumer - Insert a
Consumer<T>block instantly using a snippet. - Generate Getters and Setters - Quickly create getter and setter methods for multiple data types, improving code efficiency.
- Open VS Code.
- Navigate to the Extensions Marketplace (
Cmd + Shift + X/Ctrl + Shift + X). - Search for "EazyFlutter" and click Install.
- The extension is now ready for use.
- Select a widget in your Dart file.
- Press
Cmd + .(Mac) /Ctrl + .(Windows). - Select "Wrap with Consumer".
- Enter the Provider Type, and the extension automatically wraps the widget.
Before:
Text('Hello World')After:
Consumer<AppUserManagementProvider>(
builder: (context, appUserManagementProvider, _) {
return Text('Hello World');
},
)- Type
wrapConsumerinside your Dart file. - Press Tab, and it expands into:
Consumer<ProviderType>(
builder: (context, provider, _) {
return ChildWidget();
},
)- Replace
ProviderTypewith the actual provider class (e.g.,AuthProvider).
- Use snippets to create getter and setter methods for multiple data types, reducing manual coding effort.
Before:
String _name;After using snippet:
getSetString then Enter
Result
String _name;
String get name => _name;
set name(String value) {
_name = value;
}- Open the command palette (
Cmd + Shift + P/Ctrl + Shift + P). - Search for "EazyFlutter: JSON to Dart".
- Enter your JSON data.
- Provide a Class name for the generated model.
- The extension will:
- Generate a Dart model with
json_serializableannotations. - Save the file in
lib/models/. - Ensure proper formatting and error handling.
- Generate a Dart model with
Input JSON:
{
"id": 1,
"name": "John Doe",
"email": "john@example.com"
}Generated Dart Model:
import 'package:json_annotation/json_annotation.dart';
part 'user_model.g.dart';
@JsonSerializable()
class UserModel {
final int id;
final String name;
final String email;
UserModel({required this.id, required this.name, required this.email});
factory UserModel.fromJson(Map<String, dynamic> json) => _$UserModelFromJson(json);
Map<String, dynamic> toJson() => _$UserModelToJson(this);
}- Localization Key Prefix: Configure a prefix to use before the key when replacing in code (e.g.,
Applocalization.locale.). - Auto L10n Generate: Enable to automatically run the correct localization generation command after .arb updates. The extension detects FVM and uses
fvm flutter gen-l10nif available, otherwiseflutter gen-l10n.
- Flutter Consumer Documentation
- json_serializable Documentation
- VS Code Extension API
- QuickType Module
Enhance your Flutter development experience with EazyFlutter – making widget wrapping, state management, and JSON handling effortless!