custom_tabs_state.dart 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import 'package:flutter/cupertino.dart';
  2. class CustomTabsState {
  3. int? useTag = 0;
  4. int? activeTabIndex = 0;
  5. List? tabsList;
  6. Widget? Function(BuildContext)? tabItemBuilder;
  7. VoidCallback? onClickAction;
  8. CustomTabsState({
  9. this.useTag,
  10. this.activeTabIndex,
  11. this.tabsList,
  12. this.tabItemBuilder,
  13. this.onClickAction,
  14. });
  15. CustomTabsState copyWith({
  16. int? useTag,
  17. int? activeTabIndex,
  18. List? tabsList,
  19. Widget? Function(BuildContext)? tabItemBuilder,
  20. VoidCallback? onClickAction,
  21. }) {
  22. return CustomTabsState(
  23. useTag: useTag ?? this.useTag,
  24. activeTabIndex: activeTabIndex ?? this.activeTabIndex,
  25. tabsList: tabsList ?? this.tabsList,
  26. tabItemBuilder: tabItemBuilder ?? this.tabItemBuilder,
  27. onClickAction: onClickAction ?? this.onClickAction,
  28. );
  29. }
  30. Map<String, dynamic> toMap() {
  31. return {
  32. 'useTag': this.useTag,
  33. 'activeTabIndex': this.activeTabIndex,
  34. 'tabsList': this.tabsList,
  35. 'tabItemBuilder': this.tabItemBuilder,
  36. 'onClickAction': this.onClickAction,
  37. };
  38. }
  39. factory CustomTabsState.fromMap(Map<String, dynamic> map) {
  40. return CustomTabsState(
  41. useTag: map['useTag'] as int,
  42. activeTabIndex: map['activeTabIndex'] as int,
  43. tabsList: map['tabsList'] as List,
  44. tabItemBuilder: map['tabItemBuilder'] as Widget? Function(BuildContext),
  45. onClickAction: map['onClickAction'] as VoidCallback,
  46. );
  47. }
  48. }