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>( child: ChangeNotifierProvider<SheetStore>(
create: (BuildContext c) => store, create: (BuildContext c) => store,
child: ListenableBuilder( child: BaseSheetWidget<T?>(
listenable: store, sheetType: SheetType.form,
builder: (_, __) => BaseSheetWidget<T?>( //
sheetType: SheetType.form, sheetConfiguration: sheetConfigs,
// sheetStyle: sheetStyle,
sheetConfiguration: sheetConfigs, //
sheetStyle: sheetStyle, headSectionFormBuilder: headSectionBuilder == null ? null : (AstromicFormController controller) => headSectionBuilder.call(controller, store),
// contentSectionFormBuilder: (AstromicFormController controller) => contentSectionBuilder(controller, store),
headSectionFormBuilder: headSectionBuilder == null ? null : (AstromicFormController controller) => headSectionBuilder.call(controller, store), footerSectionFormBuilder: footerSectionBuilder == null ? null : (AstromicFormController controller) => footerSectionBuilder.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 // s2 -- Child
builder: (BuildContext context, ScrollController scrollController, ScrollPhysics scrollPhysics, int stop) { builder: (BuildContext context, ScrollController scrollController, ScrollPhysics scrollPhysics, int stop) {
return ChangeNotifierProvider<SheetStore>( return ChangeNotifierProvider<SheetStore>(
create: (BuildContext c) => SheetStore(), create: (BuildContext c) => store,
child: BaseSheetWidget<T?>( child: BaseSheetWidget<T?>(
sheetType: SheetType.scroller, sheetType: SheetType.scroller,
sheetConfiguration: sheetConfigs, sheetConfiguration: sheetConfigs,
sheetStyle: sheetStyle, sheetStyle: sheetStyle,
headSectionScrollerBuilder: headSectionBuilder == null ? null : (ScrollController controller) => headSectionBuilder.call(controller, store), 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), footerSectionScrollerBuilder: footerSectionBuilder == null ? null : (ScrollController controller) => footerSectionBuilder.call(controller, store),
scrollController: scrollController, scrollController: scrollController,
scrollPhysics: scrollPhysics, scrollPhysics: scrollPhysics,

View File

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