Flutter Policy Engine
A comprehensive policy management and access control system for Flutter applications
Flutter Policy Engine
A powerful and flexible policy management system designed specifically for Flutter applications. The Flutter Policy Engine provides comprehensive role-based access control (RBAC) capabilities with an intuitive API and seamless integration with Flutter widgets.
š Key Features
- Role-Based Access Control: Define roles with specific permissions and content access
- Dynamic Policy Management: Add, update, and remove roles at runtime
- Widget Integration: Built-in
PolicyWidget
for easy UI integration - Memory Storage: Efficient in-memory policy storage with extensible architecture
- Error Handling: Comprehensive exception handling and validation
- Type Safety: Full Dart type safety with null safety support
Architecture Overview
The Flutter Policy Engine is built with a modular architecture that separates concerns and promotes maintainability:
āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā
ā PolicyWidget ā ā PolicyProvider ā ā PolicyManager ā
ā (UI Layer) āāāāāŗā (Context) āāāāāŗā (Core Logic) ā
āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāāā
ā Policy Storage ā
ā (Memory/Extensible)ā
āāāāāāāāāāāāāāāāāāāā
PolicyManager
The central orchestrator that handles policy initialization, role management, and access evaluation.
PolicyProvider
A Flutter widget that provides policy context to the widget tree, enabling child widgets to access policy information.
PolicyWidget
A conditional widget that renders content based on the current user's role and permissions.
Role Model
A data structure representing a role with its associated permissions and allowed content.
šÆ Quick Example
// Initialize the policy manager
final policyManager = PolicyManager();
await policyManager.initialize({
"admin": ["LoginPage", "Dashboard", "UserManagement", "Settings"],
"user": ["LoginPage", "Dashboard"],
"guest": ["LoginPage"]
});
// Wrap your app with PolicyProvider
PolicyProvider(
policyManager: policyManager,
child: MaterialApp(
home: MyHomePage(),
),
);
// Use PolicyWidget for conditional rendering
PolicyWidget(
role: "admin",
content: "UserManagement",
child: UserManagementPage(),
fallback: AccessDeniedWidget(),
)
š§ Getting Started
- Installation: Add the package to your
pubspec.yaml
- Quick Start: Follow the basic setup guide
- Examples: Explore the interactive demos
- API Reference: Dive into the detailed API documentation
š Documentation Sections
- Quick Start: Get up and running in minutes
- Core Concepts: Understand the fundamental concepts
- Examples: Interactive examples and demos
- API Reference: Complete API documentation
- Advanced Topics: Best practices and advanced usage
š® Interactive Demos
The Flutter Policy Engine includes comprehensive example applications that demonstrate:
- Basic Policy Demo: Simple role-based access control
- Role Management Demo: Dynamic role creation and management
- Interactive Testing: Real-time policy testing and validation
š¤ Contributing
We welcome contributions! Please see our Contributing Guide for details.
š License
This project is licensed under the MIT License - see the LICENSE file for details.