flutter_policy_engine 1.1.0 copy "flutter_policy_engine: ^1.1.0" to clipboard
flutter_policy_engine: ^1.1.0 copied to clipboard

A lightweight, extensible policy engine for Flutter enabling Attribute-Based Access Control (ABAC) and Role-Based Access Control (RBAC) with declarative rule definitions.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_policy_engine_example/policy_engine_demo.dart';
import 'package:flutter_policy_engine_example/role_management_demo.dart';
import 'package:flutter_policy_engine_example/json_assets_demo.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Policy Engine Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomeScreen(),
    );
  }
}

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter Policy Engine Demo'),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Card(
              child: Padding(
                padding: const EdgeInsets.all(16.0),
                child: Column(
                  children: [
                    const Icon(
                      Icons.security,
                      size: 64,
                      color: Colors.blue,
                    ),
                    const SizedBox(height: 16),
                    Text(
                      'Flutter Policy Engine',
                      style: Theme.of(context).textTheme.headlineMedium,
                      textAlign: TextAlign.center,
                    ),
                    const SizedBox(height: 8),
                    Text(
                      'Interactive demo and testing tools',
                      style: Theme.of(context).textTheme.bodyLarge,
                      textAlign: TextAlign.center,
                    ),
                  ],
                ),
              ),
            ),
            const SizedBox(height: 24),
            ElevatedButton.icon(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const PolicyEngineDemo(),
                  ),
                );
              },
              icon: const Icon(Icons.play_arrow),
              label: const Text('Basic Policy Demo'),
              style: ElevatedButton.styleFrom(
                padding: const EdgeInsets.all(16),
              ),
            ),
            const SizedBox(height: 16),
            ElevatedButton.icon(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const RoleManagementDemo(),
                  ),
                );
              },
              icon: const Icon(Icons.admin_panel_settings),
              label: const Text('Role Management Demo'),
              style: ElevatedButton.styleFrom(
                padding: const EdgeInsets.all(16),
                backgroundColor: Colors.orange,
                foregroundColor: Colors.white,
              ),
            ),
            const SizedBox(height: 16),
            ElevatedButton.icon(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const JsonAssetsDemo(),
                  ),
                );
              },
              icon: const Icon(Icons.file_copy),
              label: const Text('JSON Assets Demo'),
              style: ElevatedButton.styleFrom(
                padding: const EdgeInsets.all(16),
                backgroundColor: Colors.teal,
                foregroundColor: Colors.white,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
points
31
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight, extensible policy engine for Flutter enabling Attribute-Based Access Control (ABAC) and Role-Based Access Control (RBAC) with declarative rule definitions.

Repository (GitHub)
View/report issues
Contributing

Topics

#flutter #policy #engine #authorization

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

collection, flutter, meta

More

Packages that depend on flutter_policy_engine