neurostate 0.1.3
neurostate: ^0.1.3 copied to clipboard
Intelligent, AI-augmented predictive state management for modern Flutter applications.
๐ง NeuroState #
Intelligent, AI-augmented predictive state management for modern Flutter applications.
NeuroState introduces an intelligence layer on top of traditional reactive state management.
Instead of only reacting to user events, NeuroState can predict and adapt state transitions based on:
- User behavior
- Application context
- Rule engines
- External APIs
- AI/LLM models
โจ Why NeuroState? #
Traditional state management reacts.
NeuroState predicts.
User Event โ NeuroPredictor โ Smart State Update โ UI Rebuild
This makes it ideal for:
- AI chat apps
- Smart recommendations
- Predictive UX
- Context-aware workflows
- Intelligent dashboards
โจ Features #
- ๐ง AI-augmented predictive state updates
- โก Reactive
ChangeNotifier-based architecture - ๐ Pluggable predictor system (Rules / API / ML / LLM)
- ๐งฉ Strongly typed generic state support
- ๐ก Built-in loading & error handling
- ๐ Works alongside existing state management solutions
- ๐ฆ Lightweight & flexible
๐ฆ Installation #
Add to your pubspec.yaml:
dependencies:
neurostate: ^0.1.0
Then run:
flutter pub get
๐ Quick Start (Typed Version) #
1๏ธโฃ Import Package #
import 'package:neurostate/neurostate.dart';
2๏ธโฃ Create a Strongly-Typed State Model #
class ChatState {
final bool typing;
final bool showRecommendations;
const ChatState({
this.typing = false,
this.showRecommendations = false,
});
ChatState copyWith({
bool? typing,
bool? showRecommendations,
}) {
return ChatState(
typing: typing ?? this.typing,
showRecommendations:
showRecommendations ?? this.showRecommendations,
);
}
}
3๏ธโฃ Create a Predictor #
class ChatPredictor implements NeuroPredictor<ChatState> {
ChatState _current = const ChatState();
@override
Future<ChatState> predict(
String event,
Map<String, dynamic> payload,
) async {
await Future.delayed(const Duration(milliseconds: 300));
switch (event) {
case "send_message":
_current = _current.copyWith(typing: true);
break;
case "open_cart":
_current =
_current.copyWith(showRecommendations: true);
break;
}
return _current;
}
}
4๏ธโฃ Initialize Controller #
final controller = NeuroController<ChatState>(
predictor: ChatPredictor(),
initialState: const ChatState(),
);
5๏ธโฃ Dispatch Events #
controller.dispatch("send_message", {
"text": "Hello"
});
6๏ธโฃ Listen to State in UI #
AnimatedBuilder(
animation: controller,
builder: (_, __) {
final state = controller.state;
if (controller.isLoading) {
return const CircularProgressIndicator();
}
return Column(
children: [
if (state.typing)
const Text("AI is typing..."),
if (state.showRecommendations)
const Text("Showing recommendations"),
],
);
},
);
๐ง Advanced Capabilities #
Preview State (Without Committing) #
final predicted = await controller.preview(
"open_cart",
{},
);
Useful for:
- Preloading screens
- Predictive navigation
- UI hints before committing
๐งช Example Use Cases #
- ๐ค AI Chat Applications
- ๐ Smart Recommendation Dashboards
- ๐ Predictive Analytics Panels
- ๐งพ Context-aware Form Validation
- โก Adaptive UX Personalization
- ๐ Predictive Data Preloading
๐๏ธ Architecture Overview #
NeuroState separates intelligence from UI logic.
UI Layer
โ
NeuroController<T>
โ
NeuroPredictor<T>
โ
Typed State Model
This keeps your:
- UI clean
- Business logic modular
- AI integration replaceable
- Architecture scalable
๐ฎ Roadmap #
- ๐ค OpenAI / LLM predictor integration
- ๐ Riverpod & Bloc adapters
- ๐ WebSocket streaming support
- ๐ฑ On-device ML model support
- ๐ง Intelligent caching engine
- ๐ฆ DevTools integration
๐ Why Not Just Provider or Bloc? #
NeuroState does not replace them.
It adds intelligence on top.
You can combine NeuroState with:
- Provider
- Bloc
- Riverpod
- Vanilla ChangeNotifier
NeuroState focuses on predictive logic, not dependency injection or routing.
๐ License #
MIT License.
๐ค Contributing #
Contributions, issues, and feature requests are welcome!
If youโd like to improve:
- Predictors
- Integrations
- Performance
- Documentation
Feel free to open a pull request or create an issue.
๐ Vision #
NeuroState aims to become the foundation for:
AI-native Flutter applications.