This commit is contained in:
2025-04-27 14:28:07 +03:00
parent 1dae29f031
commit cb87475c43
2 changed files with 17 additions and 14 deletions

View File

@@ -125,18 +125,15 @@ class AstromicSheetHelper {
//
child: ChangeNotifierProvider<SheetStore>(
create: (BuildContext c) => store,
child: ListenableBuilder(
listenable: store,
builder: (_, __) => BaseSheetWidget<T?>(
sheetType: SheetType.form,
//
sheetConfiguration: sheetConfigs,
sheetStyle: sheetStyle,
//
headSectionFormBuilder: headSectionBuilder == null ? null : (AstromicFormController controller) => headSectionBuilder.call(controller, store),
contentSectionFormBuilder: (AstromicFormController controller) => contentSectionBuilder(controller, store),
footerSectionFormBuilder: footerSectionBuilder == null ? null : (AstromicFormController controller) => footerSectionBuilder.call(controller, store),
),
child: BaseSheetWidget<T?>(
sheetType: SheetType.form,
//
sheetConfiguration: sheetConfigs,
sheetStyle: sheetStyle,
//
headSectionFormBuilder: headSectionBuilder == null ? null : (AstromicFormController controller) => headSectionBuilder.call(controller, store),
contentSectionFormBuilder: (AstromicFormController controller) => contentSectionBuilder(controller, store),
footerSectionFormBuilder: footerSectionBuilder == null ? null : (AstromicFormController controller) => footerSectionBuilder.call(controller, store),
),
),
);
@@ -205,13 +202,13 @@ class AstromicSheetHelper {
// s2 -- Child
builder: (BuildContext context, ScrollController scrollController, ScrollPhysics scrollPhysics, int stop) {
return ChangeNotifierProvider<SheetStore>(
create: (BuildContext c) => SheetStore(),
create: (BuildContext c) => store,
child: BaseSheetWidget<T?>(
sheetType: SheetType.scroller,
sheetConfiguration: sheetConfigs,
sheetStyle: sheetStyle,
headSectionScrollerBuilder: headSectionBuilder == null ? null : (ScrollController controller) => headSectionBuilder.call(controller, store),
contentSectionScrollBuilder: (ScrollController controller, ScrollPhysics physics) => contentSectionBuilder(controller, physics, store),
contentSectionScrollBuilder: (ScrollController controller, ScrollPhysics physics) => contentSectionBuilder(controller,physics, store),
footerSectionScrollerBuilder: footerSectionBuilder == null ? null : (ScrollController controller) => footerSectionBuilder.call(controller, store),
scrollController: scrollController,
scrollPhysics: scrollPhysics,

View File

@@ -14,6 +14,7 @@ class SheetStore extends ChangeNotifier {
static final StreamController<UnmodifiableMapView<String, dynamic>> _stateStreamController = StreamController<UnmodifiableMapView<String, dynamic>>.broadcast();
final Stream<UnmodifiableMapView<String, dynamic>> stateStream = _stateStreamController.stream;
/// Adds [item] to store.
void add(String itemID, dynamic value) {
_items.addEntries(<MapEntry<String, dynamic>>[MapEntry<String, dynamic>(itemID, value)]);
@@ -45,4 +46,9 @@ class SheetStore extends ChangeNotifier {
// This call tells the widgets that are listening to this store to rebuild.
notifyListeners();
}
/// Return a stream builder for real-time value updates.
Widget builder(Widget child) {
return ListenableBuilder(listenable: this, builder: (_,__) => child);
}
}