easy_dev_core 0.0.4
easy_dev_core: ^0.0.4 copied to clipboard
Core utilities, failures, and extensions for Easy Dev Toolkit.
Easy Dev Core #
The foundational layer of the Easy Dev Toolkit. This package provides essential utilities, functional error handling, advanced logging, and responsive helpers that power the rest of the ecosystem.
Features #
1. Functional Error Handling (Result<T, E>) #
Stop using try-catch blocks for expected logic flows. Use Result to explicitly handle success and failure.
import 'package:easy_dev_core/easy_dev_core.dart';
// 1. Return a Result
Result<int, String> divide(int a, int b) {
if (b == 0) return Result.error('Cannot divide by zero');
return Result.ok(a ~/ b);
}
void main() {
final result = divide(10, 2);
// 2. Handle with match
result.match(
(value) => print('Success: $value'),
(error) => print('Error: $error'),
);
// 3. Or check explicitly
if (result.isSuccess) {
print(result.unwrap);
}
}
2. Clean Logger (CleanLogger) #
A leveled logger with emoji support to keep your debug output readable.
CleanLogger.info('App initialized'); // ℹ️ [INFO] App initialized
CleanLogger.debug('User ID: 123'); // 🐛 [DEBUG] User ID: 123
CleanLogger.warning('Battery low'); // ⚠️ [WARN] Battery low
CleanLogger.error('Connection failed', // ❌ [ERROR] Connection failed
error: e,
stackTrace: s
);
3. Event Transformers (EasyDebounce, EasyThrottle) #
Manage rapid user inputs effortlessly.
final debouncer = EasyDebounce(delay: Duration(milliseconds: 500));
// Call this on every keystroke
void onSearchChanged(String query) {
debouncer.run(() {
// API call happens only after 500ms of inactivity
searchApi(query);
});
}
4. Responsive & Context Extensions #
Build adaptvie UIs with less boilerplate.
// In build(BuildContext context)
if (context.isTablet) { ... }
if (context.isLandscape) { ... }
// Size config
10.h; // 10% of screen height
20.w; // 20% of screen width
12.sp; // 12 scalable pixels
5. Easy Validator (EasyValidator) #
Build form validation logic with a clean, chainable API.
TextFormField(
validator: EasyValidator()
.required()
.email()
.minLength(6)
.build(),
);
Installation #
dependencies:
easy_dev_core: ^0.0.2