ScreenUtil Helper
Author: Mohamed Maher
Description
The ScreenUtil Helper is a VS Code extension designed to automate the addition of .h
, .w
, .sp
, and .r
suffixes in Flutter projects, ensuring screen compatibility with minimal effort. Using Regular Expressions, this extension helps save time by automatically applying the appropriate suffixes to height, width, fontSize, padding, and margin values.
Features
- Adds
.h
to height values.
- Adds
.w
to width values.
- Adds
.sp
to font size values.
- Replaces
EdgeInsets.all
with .r
for responsive design.
This automation eliminates the need for manual editing, saving time and reducing errors in Flutter projects.
How to Use
- Open a Dart/Flutter project in VS Code.
- Run the command "Run ScreenUtil Helper" by pressing
Ctrl+Shift+P
(or Cmd+Shift+P
on Mac).
- The extension will automatically search and replace the following patterns in your code:
height: <number>
➡️ height: <number>.h
width: <number>
➡️ width: <number>.w
fontSize: <number>
➡️ fontSize: <number>.sp
EdgeInsets.all(<number>)
➡️ EdgeInsets.all(<number>.r)
Example
Before running ScreenUtil Helper:
Container(
height: 100,
width: 200,
fontSize: 16,
padding: EdgeInsets.all(10),
)
After running ScreenUtil Helper:
Container(
height: 100.h,
width: 200.w,
fontSize: 16.sp,
padding: EdgeInsets.all(10.r),
)