coderx 0.0.2 copy "coderx: ^0.0.2" to clipboard
coderx: ^0.0.2 copied to clipboard

A simple, fast Flutter state management tool for theme, locale, and UI with builder, listener, and reactive state support.

coderx #

A lightweight and reactive state management system for Flutter. Easily manage global or local state, handle async states, computed values, and react to changes with builders, consumers, listeners, and observers โ€” all with simple Dart classes.

๐Ÿš€ Features #

โœ… Simple and lightweight ๐Ÿ”„ Reactive updates with ChangeNotifier ๐Ÿ’ฅ Built-in builder, listener, observer, and consumer widgets ๐Ÿ“ฆ Global or local state ๐ŸŒ App config (theme, locale) management ๐Ÿงฎ Computed values (CoderComputed) ๐Ÿ” Async state (CoderAsync)

๐Ÿ“ฆ Installation #

Add this to your pubspec.yaml:

dependencies:
  coderx: ^latest_version

๐Ÿ› ๏ธ Basic Usage #

๐Ÿ”น Import

import 'package:coderx/coderx.dart';

๐Ÿ”น Create a State

final counter = CoderState<int>(0);

๐Ÿ”น Use CoderConsumer to rebuild on state change

CoderConsumer<int>(
  state: counter,
  builder: (context, count) => Text('Count: $count'),
);

๐Ÿ”น Update State

counter.value++;

๐Ÿงฑ Multi-State Consumption #

Use CoderMultiConsumer to listen to multiple states.

CoderMultiConsumer(
  states: [themeMode, locale],
  builder: (context) {
  return MaterialApp(
      themeMode: themeMode.value,
      locale: locale.value,
      home: const HomeScreen(),
    );
  },
);

๐ŸŽง Listen for State Changes (Side Effects)

CoderListener<String?>(
  state: errorState,
  listener: (context, value) {
    if (value != null) {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(content: Text("Error: $value")),
      );
    }
  },
  child: const HomeScreen(),
);

๐Ÿงฎ Computed State

final username = CoderState<String>("Guest");

final welcomeMessage = CoderComputed<String>(
  compute: () => "๐Ÿ‘‹ Welcome, ${username.value}!",
  dependencies: [username],
);

๐Ÿ”„ Async State

final userAsync = CoderAsync<List<String>>();

Future<void> loadUsers() async {
  await userAsync.run(() async {
    await Future.delayed(Duration(seconds: 2));
    return ['Alice', 'Bob', 'Charlie'];
  });
}

// Display UI based on async state
CoderConsumer<CoderAsyncState<List<String>>>(
  state: userAsync.state,
  builder: (context, async) {
    if (async.isLoading) return CircularProgressIndicator();
    if (async.hasError) return Text("Error: ${async.error}");
    if (async.hasData) return Column(
      children: async.data!.map((e) => Text(e)).toList(),
    );
    return SizedBox();
  },
);

#### โš™๏ธ AppConfig (Global States)
```dart
class AppConfig {
  final themeMode = CoderState<ThemeMode>(ThemeMode.light);
  final locale = CoderState<Locale>(const Locale('en'));
  final counter = CoderState<int>(0);
  final username = CoderState<String>('Guest');
  final loading = CoderState<bool>(false);
  final error = CoderState<String?>(null);
  final userList = CoderState<List<String>>([]);
  
  late final welcomeMessage = CoderComputed<String>(
    compute: () => "๐Ÿ‘‹ Welcome, ${username.value}!",
    dependencies: [username],
  );
  
  static final AppConfig _instance = AppConfig._internal();
  factory AppConfig() => _instance;
  AppConfig._internal();
}

final config = AppConfig();

๐Ÿš€ About Me #

๐Ÿ‘จโ€๐Ÿ’ป Senior Flutter Developer
๐Ÿ’ก One principle I always code by:
"Donโ€™t just develop โ€” Develop Innovative"

๐Ÿ“ Author Profile #

coderspacedev
linkedin
Stack_Overflow

Support #

Feel free to contribute or raise issues. For support, email thoriyaprahalad@gmail.com

0
likes
160
points
27
downloads

Publisher

verified publishercoderdev.space

Weekly Downloads

A simple, fast Flutter state management tool for theme, locale, and UI with builder, listener, and reactive state support.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

cupertino_icons, flutter

More

Packages that depend on coderx