titan_bastion 0.2.0 copy "titan_bastion: ^0.2.0" to clipboard
titan_bastion: ^0.2.0 copied to clipboard

Flutter widgets for Titan state management. Vestige, Beacon, and auto-tracking reactive UI with Pillar architecture.

example/main.dart

/// Titan Bastion — Flutter widgets for Titan state management.
///
/// This example demonstrates:
/// - [Pillar] — Reactive state module
/// - [Beacon] — Widget-tree DI provider
/// - [Vestige] — Auto-tracking consumer widget
library;

import 'package:flutter/material.dart';
import 'package:titan_bastion/titan_bastion.dart';

// ---------------------------------------------------------------------------
// Pillar — Reactive state
// ---------------------------------------------------------------------------

class CounterPillar extends Pillar {
  late final count = core(0);
  late final doubled = derived(() => count.value * 2);

  void increment() => strike(() => count.value++);
  void decrement() => strike(() => count.value--);
}

// ---------------------------------------------------------------------------
// App
// ---------------------------------------------------------------------------

void main() {
  runApp(
    // Beacon provides Pillar instances to the widget tree
    Beacon(
      pillars: [CounterPillar.new],
      child: const MaterialApp(home: CounterScreen()),
    ),
  );
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Titan Counter')),
      // Vestige auto-tracks which Cores are read and rebuilds on change
      body: Vestige<CounterPillar>(
        builder: (context, pillar) => Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text(
                '${pillar.count.value}',
                style: Theme.of(context).textTheme.displayLarge,
              ),
              const SizedBox(height: 8),
              Text('Doubled: ${pillar.doubled.value}'),
            ],
          ),
        ),
      ),
      floatingActionButton: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          FloatingActionButton(
            heroTag: 'increment',
            onPressed: () => context.pillar<CounterPillar>().increment(),
            child: const Icon(Icons.add),
          ),
          const SizedBox(height: 8),
          FloatingActionButton(
            heroTag: 'decrement',
            onPressed: () => context.pillar<CounterPillar>().decrement(),
            child: const Icon(Icons.remove),
          ),
        ],
      ),
    );
  }
}
1
likes
160
points
337
downloads
screenshot

Publisher

verified publisherikolvi.com

Weekly Downloads

Flutter widgets for Titan state management. Vestige, Beacon, and auto-tracking reactive UI with Pillar architecture.

Homepage
Repository (GitHub)
View/report issues

Topics

#state-management #flutter #reactive #widget #signals

Documentation

API reference

License

MIT (license)

Dependencies

flutter, titan

More

Packages that depend on titan_bastion