stateplus 0.1.0-dev.1 copy "stateplus: ^0.1.0-dev.1" to clipboard
stateplus: ^0.1.0-dev.1 copied to clipboard

A minimal, high-performance reactive state management and navigation solution for Flutter. StatePlus is designed to eliminate boilerplate, avoid unnecessary rebuilds, and unify state + navigation int [...]

example/lib/main.dart

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

/// =======================================================
/// APP STATE
/// =======================================================

final counter = Signal<int>(0);
final doubleCounter = Computed(() => counter.value * 2);
final router = RouteState();

/// =======================================================
/// APP ENTRY
/// =======================================================

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'StatePlus Demo',
      home: StateRouter(
        router: router,
        routes: {
          '/': () => const HomePage(),
          '/details': () => const DetailsPage(),
        },
      ),
    );
  }
}

/// =======================================================
/// PAGES
/// =======================================================

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Home')),
      body: Center(
        child: StateWidget(
          builder: () => Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text(
                'Counter: ${counter.value}',
                style: const TextStyle(fontSize: 22),
              ),
              Text(
                'Double: ${doubleCounter.value}',
                style: const TextStyle(fontSize: 18),
              ),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () => counter.value++,
                child: const Text('Increment'),
              ),
              const SizedBox(height: 8),
              ElevatedButton(
                onPressed: () => router.go('/details'),
                child: const Text('Go to Details'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Details')),
      body: Center(
        child: ElevatedButton(
          onPressed: () => router.go('/'),
          child: const Text('Back to Home'),
        ),
      ),
    );
  }
}
0
likes
0
points
126
downloads

Publisher

unverified uploader

Weekly Downloads

A minimal, high-performance reactive state management and navigation solution for Flutter. StatePlus is designed to eliminate boilerplate, avoid unnecessary rebuilds, and unify state + navigation into a single reactive system.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on stateplus