Section constructor

const Section({
  1. Key? key,
  2. Widget? customHeader,
  3. bool initiallyExpanded = true,
  4. bool expandable = false,
  5. required Widget child,
  6. BarBackButtonMode backButton = BarBackButtonMode.never,
  7. Widget? title,
  8. Widget? subtitle,
  9. Widget? header,
  10. String? titleText,
  11. String? subtitleText,
  12. String? headerText,
  13. List<Widget> leading = const [],
  14. List<Widget> trailing = const [],
})

Constructs a new Section instance.

The child parameter is required and defines the main content area. All other parameters are optional and customize the header and behavior.

If customHeader is provided, the widget initializes a GlassSection with the custom header and converts the child to a sliver if necessary. Otherwise, it initializes a BarSection using the provided title, subtitle, leading, trailing, and back button configurations.

Defaults:

  • initiallyExpanded: true (section starts expanded if expandable).
  • expandable: false (non-collapsible by default).
  • backButton: BarBackButtonMode.never (no back button shown).
  • leading and trailing: Empty lists [].

The key parameter is inherited from StatelessWidget for widget identification in the tree.

Implementation

const Section({
  super.key,
  this.customHeader,
  this.initiallyExpanded = true,
  this.expandable = false,
  required this.child,
  this.backButton = BarBackButtonMode.never,
  this.title,
  this.subtitle,
  this.header,
  this.titleText,
  this.subtitleText,
  this.headerText,
  this.leading = const [],
  this.trailing = const [],
});