Skip to content
pubscout

cubes

1.5.5, released 4 years ago by an unverified publisher

Simple state manager with built‑in dependency injection using observable values.

WASM-ready
$ flutter pub add cubes
Source repository

What it does

Cubes lets you create Cube classes that hold business logic and expose ObservableValues. Widgets rebuild only when those observables change, and Cubes are provided via a lightweight DI container.

AI-written summary of version 1.5.5, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need lightweight state management without code generation.
  • You want built‑in DI and fine‑grained widget rebuilds.

Skip it when

  • Your app requires complex stream handling or advanced state features like bloc or riverpod.
  • You rely heavily on code‑gen tools for boilerplate reduction.

Strengths

  • No code‑generation step required.
  • Fine‑grained rebuilds improve performance.
  • Integrated DI simplifies object creation.

Weaknesses

  • Smaller ecosystem compared to popular state libraries.
  • Limited advanced features (e.g., middleware, testing utilities).

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:cubes/cubes.dart';
import 'package:flutter/material.dart';

void main(){
  Cubes.registerFactory((i)=>CounterCube());
  runApp(MaterialApp(home: CounterScreen()));
}

class CounterCube extends Cube{final count=0.obs;void increment()=>count.modify((v)=>v+1);}

class CounterScreen extends CubeWidget<CounterCube>{
  const CounterScreen({Key?key}):super(key:key);
  @override
  Widget buildView(BuildContext ctx, CounterCube c){
    return Scaffold(
      body: Center(child: c.count.build<int>((v)=>Text('$v'))),
      floatingActionButton: FloatingActionButton(onPressed:c.increment,child:Icon(Icons.add)),
    );
  }
}

Alternatives

Packages that do the same job and could replace cubes.

Works with

Packages commonly used together with cubes: ones it builds on, ones built on it, and its own family.