Welcome to the IEngine Framework! IEngine is a lightweight and beginner-friendly framework designed to simplify Flutter development by reducing boilerplate and offering a clean, intuitive structure. Whether you're building apps or packages, IEngine helps you move faster with less code and more clarity.
π Features of iEngine
The iEngine framework provides a simplified and powerful foundation for building Flutter apps with minimal boilerplate. Hereβs what it offers:
β Core Initialization
- Ensures
WidgetsFlutterBindingis initialized before app launch. - Handles shared preferences setup automatically via
Prefs.instance().
π§ State-Free Utilities
- Access preferences globally without
asyncor boilerplate. - Simplified app entry point with
IEngine.run(MyApp());.
π― Built-in Extensions
BuildContextextensions for screen size and platform detection.Colorextensions for easier color manipulation and themes.Pathextensions to simplify file and route handling.
π¨ Custom Canvas Tools
- Includes
ICanvasutilities and a flexibleIPaintersystem. - Easily create custom drawings and visual effects and it uses
AnimationControllerfor dynamic effects.
π HTTP Support Out-of-the-box
- Built-in support for the
httppackage. - Simplifies common networking operations with
dart:convert.
βοΈ Platform Aware
- Handles both mobile and desktop environments with smart checks using
PlatformandkIsWeb.
π§βπ» Getting Started
To start using iEngine in your Flutter project:
-
Add the package to your
pubspec.yaml: -
Import and use
IEnginein yourmain.dart:
β οΈ Important:
You must use IEngine.run() instead of runApp() to ensure Flutter bindings and shared preferences (Prefs) are properly initialized before your app starts.
Skipping this may cause unexpected behavior or null values when accessing preferences.
π οΈ Usage
βΆοΈ IEngine.run()
Use IEngine.run() as the entry point of your Flutter app instead of the default runApp().
This ensures proper initialization of Flutter bindings and shared preferences before the app starts.
β Example:
import 'package:ingine/engine.dart';
void main() {
IEngine.run(MyApp());
}
πΎ Prefs
Prefs is a simple wrapper around SharedPreferences that allows easy access to persistent storage without boilerplate or needing async in your widgets.
It is automatically initialized when you use IEngine.run().
β Get values:
String username = Prefs.getString('username');
int score = Prefs.getInt('score');
bool isDarkMode = Prefs.getBool('dark_mode');
β Set values:
await Prefs.setString('username', 'Ibrahim');
await Prefs.setInt('score', 100);
await Prefs.setBool('dark_mode', true);
β utils:
Prefs.contains('username'); // Check if key exists
await Prefs.remove('username'); // Remove specific key
await Prefs.clear(); // Clear all preferences
π§© Core Dart Extensions
The extensions.dart file provides handy extensions for commonly used Dart types like String, num, and Object, making your code cleaner and more expressive.
Object Extension
- Paste Text
final text = await Object().paste(); // or
final pastedString = await any.paste();
print('Pasted: $text');
String Extension
- Fetch JSON from URL
final data = await 'https://api.example.com/data'.fetchJson();
print(data['key']);
- Copy to Clipboard
'Copied text'.copyToClipboard(); // Basic usage
'Copied text'.copyToClipboard(context); // With toast message ('Copied!')
'Copied text'.copyToClipboard(context, 'Copied to clipboard!'); // With custom toast message
- Email Validation
if ('example@email.com'.isEmail) {
print('Valid email!');
}
π§ͺ Number Extension
- Range Check
if (value.inRange(10, 20)) {
print('Value is between 10 and 20');
}
πΌοΈ BuildContext Extensions
ContextExtensions provides useful properties directly on BuildContext to help identify screen size, platform, and orientation β all without boilerplate.
π Screen Size Checks
context.isMobile; // true if width < 600
context.isTablet; // true if width between 600 and 800
context.isDesktop; // true if width > 1024
π Orientation Checks
if (context.isLandscape) {
print('Landscape mode');
} else if (context.isPortrait) {
print('Portrait mode');
}
π¨ Color Extension
ColorUtils adds a simple way to adjust the brightness of any Color using HSL-based logic.
π Adjust Brightness
final baseColor = Colors.blue;
// Make the color slightly brighter
final brighter = baseColor.brightness(0.7);
// Make the color slightly darker
final darker = baseColor.brightness(0.3);
βοΈ Path Extension
PathExtension adds a utility to draw smooth curves between a list of points using quadratic BΓ©zier curves.
β° Add a Smooth Curve to a Path
final points = [
Offset(0, 0),
Offset(50, 100),
Offset(100, 50),
Offset(150, 150),
];
final path = Path().addSmoothCurve(points);
Platforms
- Detects the platform safely using conditional imports.
- Supports:
- βοΈ Android
- βοΈ iOS
- βοΈ Web
- βοΈ Windows
- βοΈ macOS
- βοΈ Linux
- Avoids using
dart:ioon Web or unsupported platforms like WASM.
Usage
import 'package:ingine/platform.dart';
if (isWeb) {
print("Running on Web");
} else if (isAndroid) {
print("Running on Android");
} else if (isIOS) {
print("Running on iOS");
} else if (isWindows) {
print("Running on Windows");
}
ποΈ ICanvas & IPainter
The ICanvas widget and IPainter class provide a lightweight framework for building animated, interactive custom canvas drawings using CustomPaint, animation controllers, and reusable rendering logic.
π¨ How It Works
ICanvasis a widget that wrapsCustomPaintand handles:- Canvas size tracking
- Re-initializing on resize
- Animation control via
ValueNotifier
IPainteris an abstract base class where you:- Set up animations
- Override the
rendermethod to draw on the canvas - Manage lifecycle (init, update, dispose)
β Example Usage
class MyEffect extends IPainter {
late AnimationController _controller;
late Animation<double> _radius;
@override
void onInit(TickerProvider vsync) {
_controller = createController(
vsync: vsync,
duration: const Duration(seconds: 2),
repeat: true,
);
_radius = createAnimation(
vsync: vsync,
controller: _controller,
tween: Tween<double>(begin: 0, end: 100),
listener: update,
);
}
@override
void render(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.blue;
canvas.drawCircle(center, _radius.value, paint);
}
}
π¦ Additional Information
For more details, documentation, and updates, visit the official repository:
π GitHub: https://github.com/IbrahimKhatrii/ingine
π€ Contributing
Contributions are welcome!
If you'd like to contribute to iEngine, feel free to fork the repository, make your changes, and submit a pull request. Please follow existing code style and conventions.
π Issues & Feedback
Found a bug or have a feature request? Please open an issue on the GitHub repository. We actively monitor and try to respond quickly to all issues and suggestions.
π¬ Contact
If you have any questions or need help using the package, reach out via the Issues section or discussions tab on GitHub.
Thanks for using iEngine β A lightweight and developer-friendly way to power your Flutter apps!
Libraries
- engine
- iEngine.dart
- example/ingine_example
- iEngine/prefs
- Provides shared preferences utilities via the Prefs class.
- platform
- Provides platform detection utilities (web, Android, iOS, etc.)