penta_core 2.1.0
penta_core: ^2.1.0 copied to clipboard
A package for Penta Core, a Flutter package that provides a set of utilities and tools to help developers build high-quality applications quickly and efficiently.
Flutter Penta Core Package #
A comprehensive Flutter package that provides a rich set of utilities, widgets, extensions, and services to accelerate Flutter application development. This package is designed to be modular, extensible, and developer-friendly.
π¦ Package Information #
- Package Name:
penta_core - Repository: GitHub
π§ Setup #
Locale Management Setup #
- Generate Locale Keys:
flutter pub run penta_core:lang_generator <input_json_file_path> <output_folder_path> <output_class_name>
Example:
flutter pub run penta_core:lang_generator ./assets/lang/en.json ./lib/generated LocaleKeys
Important: The enum names must match the JSON file names exactly. For example:
- Option 1:
AppLocale.enshould correspond toen.jsonAppLocale.trshould correspond totr.json
- Option 2:
AppLocale.enUSshould correspond toenUS.jsonAppLocale.trTRshould correspond totrTR.json
- Initialize in main.dart:
import 'package:penta_core/penta_core.dart';
// -- Option 1: Using simple locale codes --
enum AppLocale { en, tr }
// -- Option 2: Using full locale codes --
// enum AppLocale { enUS, trTR }
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await LocaleManager.I.initialize(
assetFolderPath: 'assets/translations',
enumValues: AppLocale.values,
);
runApp(
LocaleManagerProvider.create(
defaultLocale: AppLocale.en,
child: const MainApp(),
),
);
}
- Usage in Widgets:
import 'package:penta_core/penta_core.dart';
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(LocaleKeys.greeting.tr())),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
final newLocale =
context.localeManagerNotifierRead.currentLocale ==
AppLocale.en
? AppLocale.tr
: AppLocale.en;
context.localeManagerNotifierRead.changeLocale(newLocale);
},
child: Text(LocaleKeys.changeLanguage.tr()),
),
Text(LocaleKeys.testArgs1.trWithArgs(['ARG 1'])),
Text(LocaleKeys.testMultiArgs2.trWithArgs(['ARG 1', 'ARG 2'])),
Text(
LocaleKeys.testNamedArgs2.trWithNamedArgs({
'name': 'John',
'age': '20',
}),
),
],
),
),
);
}
}
π Features #
π― Constants & Values #
- App Values: Centralized application constants
- Email Validation: Email validation constants
π§ Extensions #
- App Values Extensions: Centralized app constants, padding, radius, and size value management
- Bool Extensions: Boolean operations, conditional logic, and type conversions
- Color Extensions: Material color utilities, color manipulation, and theme integration
- Context Extensions: Screen dimensions, theme access, locale management, and widget context helpers
- DateTime Extensions: Formatting, calculation, comparison utilities, and time-based operations
- Int Extensions: Mathematical calculations, digit counting, and number formatting
- Iterable Extensions: Generic collection operations, filtering, and iteration helpers
- List Extensions: Sorting, filtering, manipulation helpers, and collection operations
- Map Extensions: Key-value pair manipulation, filtering, and transformation utilities
- Number Extensions: Math operations, linear interpolation, and numerical conversions
- String Extensions: Validation, conversion, random string generation, and text manipulation utilities
- Uint8List Extensions: Byte array conversion, encoding/decoding, and binary data manipulation
- Widget Extensions: Sliver widgets, widget manipulation, and UI component utilities
π Managers #
- Locale Management: Complete locale management system with easy switching
π± Models & Mixins #
- Response Models: Standardized API response handling and data structure management
- Error Models: Error handling, management, and error state representation
- Use Case Models: Clean architecture use case patterns with various parameter and response combinations
- Object Models: Base model classes with ID support and common object operations
- Material Models: Material Design color and theme model implementations
- State Mixins: Safe state management for widgets with lifecycle handling
- Repository Mixins: Data repository patterns and data access layer abstractions
π Services & Utilities #
- Cache Service: Interface for caching operations and data persistence
- Router Service: Navigation and routing interface for app navigation
- Connectivity Service: Internet connection checking and network status monitoring
- Event Bus: Application-wide event management and communication system
- Debouncer: Input debouncing utilities for search, API calls, and user interactions
- Loading Dialog: Callback-based loading dialogs with async operation handling
- Firebase Exception Converter: Multi-language Firebase error message conversion and localization
- Image String Converter: Universal image provider creation from URLs, assets, files, and base64 data
- Timestamp Converter: DateTime and timestamp conversion utilities for local and UTC time handling
π¨ Widgets #
- Field Widgets: International phone number input with country selection, supporting 25+ languages with customizable UI, validation, and country code detection
- Layout Widgets: Adaptive and responsive design widgets that automatically adjust to different screen sizes and platforms (mobile, desktop, web), plus padding management utilities
- Overlay Widgets: Showcase widgets for user onboarding, feature highlighting, and interactive overlays
- Padding Widgets: Smart padding management with selective padding application and escape mechanism for specific widgets
- Painter Widgets: Custom drawing widgets including arrow painters for connecting UI elements with arrows
- SizedBox Widgets: Gap widgets for flexible spacing and layout management with customizable dimensions and colors
- Text Widgets: Enhanced text widgets with customizable underline support, clickable text spans, and rich text formatting
- Toast Widgets: Toast notifications with customizable positioning, animations, and styling for user feedback
π Architecture #
The package follows a modular architecture with clear separation of concerns:
lib/src/
βββ constants/ # Application constants and values
βββ extensions/ # Dart class extensions
βββ managers/ # Application-wide managers
βββ mixins/ # Reusable mixins
βββ models/ # Data models and interfaces
βββ services/ # Service interfaces
βββ utils/ # Utility classes
βββ widgets/ # Reusable widgets
π Supported Languages (Phone Field) #
The phone field widget supports 25+ languages:
- Arabic (ar), Bengali (bn), Chinese (zh)
- Dutch (nl), English (en), French (fr)
- German (de), Greek (el), Hindi (hi)
- Indonesian (id), Italian (it), Japanese (ja)
- Korean (ko), Persian (fa), Polish (pl)
- Portuguese (pt), Russian (ru), Spanish (es)
- Swedish (sv), Thai (th), Turkish (tr)
- Ukrainian (uk), Urdu (ur), Vietnamese (vi)
π License #
This project is licensed under the MIT License. See the LICENSE file for details.
π Links #
π Support #
If you encounter any issues or have questions, please:
- Check the GitHub Issues
- Create a new issue with detailed information
- Contact the maintainer
Made with β€οΈ for the Flutter community