FlutterArtist Scalar External Shelf Event ex1
In the FlutterArtist, the power of broadcasting is not limited to Blocks. Scalar — the component representing single values or aggregate reports — also possesses the ability to listen and react intelligently to events from other Shelves:
For simplicity consider the illustration below:

When you try to add, delete or modify an ItemA1 on BlockA1 (Of ShelfA), an event will be emitted outside of ShelfA and sent to ShelfB. Suppose that ScalarB1 has heard this event. ScalarB1's SCALAR-level reaction can be a requery.
Note: You should see a basic Scalar example in the article below before continuing with this article:
- FlutterArtist SingleItemBlock ex1 (***)
Example Scenario: Demo24a
SystemReport24aScalar displays aggregate system metrics such as: category count (categoryCount), employee count (employeeCount), and supplier count (supplierCount).
Scalar Value
{
"categoryCount": 3,
"employeeCount": 20,
"noteCount": 8,
"productCount": 31,
"supplierCount": 4,
"saleOrderCount": 304
}From the SystemReport24aScalar interface, the user clicks the "Create Supplier" button to invoke the SingleSupplierBlock Form (belonging to SingleSupplierShelf) to create a new supplier. A successful save action on this Shelf will broadcast an external event. SystemReport24aScalar listens for that event and automatically triggers a re-query to update the latest report figures.

No ADS

- Download FlutterArtist Demo
2. SystemReport24aShelf
Use the ScalarConfig.onExternalShelfEvents property to define the event "frequencies" this Scalar will respond to.
No ADS
system_report24a_shelf.dart
class SystemReport24aShelf extends Shelf {
@override
ShelfStructure defineShelfStructure() {
return ShelfStructure(
filterModels: {},
blocks: [],
scalars: [
SystemReport24aScalar(
name: SystemReport24aScalar.scalarName,
description: null,
filterModelName: null,
config: ScalarConfig(
onExternalShelfEvents: ExternalShelfEventScalarRecipient(
scalarLevelReactionOn: [
Event(SupplierInfo), //
Event(SupplierData), //
Event(ProductData), // Others...
],
),
),
),
],
);
}
SystemReport24aScalar findSystemReport24aScalar() {
return findScalar(SystemReport24aScalar.scalarName)
as SystemReport24aScalar;
}
}
- FlutterArtist Projections (***)
3. SystemReport24aScalar
The Scalar performs the actual query logic via the performQuery() method. When a matching external event occurs, the Framework automatically triggers this method.
system_report24a_scalar.dart
class SystemReport24aScalar extends Scalar<
SystemReportData, // VALUE
EmptyFilterInput,
EmptyFilterCriteria> {
static const scalarName = "system-report24a-scalar";
final systemReportRestProvider = SystemReportRestProvider();
SystemReport24aScalar({
required super.name,
required super.description,
required super.config,
required super.filterModelName,
}) : super(childScalars: const []);
@override
Future<ApiResult<SystemReportData>> performQuery({
required Object? parentScalarValue,
required EmptyFilterCriteria filterCriteria,
}) async {
return await systemReportRestProvider.query();
}
}4. SystemReport24aButtons
system_report24a_buttons.dart
class SystemReport24aButtons extends ScalarSectionView<SystemReport24aScalar> {
const SystemReport24aButtons({super.key, required super.scalar});
@override
Widget buildContent(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ElevatedButton(
onPressed: () {
_onPressCreateSupplierBtn(context);
},
child: Text("Create Supplier"),
),
],
);
}
Future<void> _onPressCreateSupplierBtn(BuildContext context) async {
FlutterArtist.codeFlowLogger.addMethodCall(
ownerClassInstance: this,
currentStackTrace: StackTrace.current,
parameters: null,
);
//
Coordinator coordinator = SingleSupplierCreationCoordinator(
config: CoordinatorConfig(),
customNavigate: (BuildContext context, bool success) {
if (success) {
Scaffold.of(context).openEndDrawer();
}
},
);
await coordinator.execute(context);
}
}No ADS
FlutterArtist
- Basic concepts in Flutter Artist
- FlutterArtist Block ex1
- FlutterArtist Filter Example
- FlutterArtist FilterModel MultiOptFilterCriterion ex1
- FlutterArtist FilterInput Example 1
- FlutterArtist Form ex1
- The idea of designing filter models in FlutterArtist
- FlutterArtist FormModel.patchFormFields() Ex1
- FlutterArtist BlockQuickItemUpdateAction Example
- FlutterArtist BlockNumberPagination Ex1
- FlutterArtist GridView Infinite Scroll Example
- FlutterArtist BlockQuickMultiItemCreationAction Example
- FlutterArtist ListView Infinite Scroll Pagination Example
- FlutterArtist Pagination
- FlutterArtist Sort DropdownSortPanel Example
- FlutterArtist Dio
- FlutterArtist BlockBackendAction Example
- FlutterArtist BackgroundWebDownloadAction Example
- FlutterArtist StorageBackendAction ex1
- FlutterArtist Block External Shelf Event ex1
- FlutterArtist Filter FormBuilderMultiDropDown Ex1
- FlutterArtist Master-detail Blocks ex1
- FlutterArtist Scalar ex1
- FlutterArtist Pagination Davi table Infinite Scroll Ex1
- FlutterArtist Filter Tree FormBuilderField ex1
- FlutterArtist Filter FormBuilderRadioGroup ex1
- FlutterArtist Form Parent-child MultiOptFormProp ex1
- FlutterArtist Manual Sorting ReorderableGridView Example
- FlutterArtist Manual Sorting ReorderableListView
- FlutterArtist Scalar External Shelf Event ex1
- FlutterArtist Code Flow Viewer
- FlutterArtist Log Viewer
- FlutterArtist config
- FlutterArtist StorageStructure
- FlutterArtist Debug Storage Viewer
- FlutterArtist DebugMenu
- FlutterArtist Debug UI Components Viewer
- FlutterArtist Debug Shelf Structure Viewer
- FlutterArtist Context Provider Views
- FlutterArtist FilterModelStructure ex1
- FlutterArtist FilterModelStructure ex2
- FlutterArtist FilterModelStructure ex3
- FlutterArtist Internal Shelf Event ex1
- FlutterArtist Deferring External Shelf Events (Ex1)
- FlutterArtist DropdownSortPanel
Show More
