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.  
  18. ///call in view
  19. Widget buildItemView(ItemState state, Dispatch dispatch, ViewService service) {
  20. return Scaffold(
  21. body: Stack(
  22. children: <Widget>[
  23. service.buildComponent('body'),
  24. service.buildComponent('ad_ball'),
  25. Positioned(
  26. child: service.buildComponent('bottomBar'),
  27. left: 0.0,
  28. bottom: 0.0,
  29. right: 0.0,
  30. height: 100.0,
  31. ),
  32. ],
  33. ),
  34. appBar: AppbarPreferSize(child: service.buildComponent('appBar')));
  35. }