Dependencies

  • Dependencies is a structure that expresses dependencies between components. It accepts two fields
  • It mainly contains three aspects of information
    • The slots that the component depends on.
    • The adapter that the component depends on (used to build a high-performance ListView).
    • Dependent Is a combination of subComponent | subAdapter + connector
    • A component’s Reducer is automatically compounded by the Reducer configured by the Component itself and all of the Reducers under its Dependencies.
  • Sample Code
  1. ///register in component
  2. class ItemComponent extends ItemComponent<ItemState> {
  3. ItemComponent()
  4. : super(
  5. view: buildItemView,
  6. reducer: buildItemReducer(),
  7. dependencies: Dependencies<ItemState>(
  8. slots: <String, Dependent<ItemState>>{
  9. 'appBar': AppBarComponent().asDependent(AppBarConnector()),
  10. 'body': ItemBodyComponent().asDependent(ItemBodyConnector()),
  11. 'ad_ball': ADBallComponent().asDependent(ADBallConnector()),
  12. 'bottomBar': BottomBarComponent().asDependent(BottomBarConnector()),
  13. },
  14. ),
  15. );
  16. }
  17. ///call in view
  18. Widget buildItemView(ItemState state, Dispatch dispatch, ViewService service) {
  19. return Scaffold(
  20. body: Stack(
  21. children: <Widget>[
  22. service.buildComponent('body'),
  23. service.buildComponent('ad_ball'),
  24. Positioned(
  25. child: service.buildComponent('bottomBar'),
  26. left: 0.0,
  27. bottom: 0.0,
  28. right: 0.0,
  29. height: 100.0,
  30. ),
  31. ],
  32. ),
  33. appBar: AppbarPreferSize(child: service.buildComponent('appBar')));
  34. }