ChartContainer constructor

const ChartContainer({
  1. Key? key,
  2. required Widget child,
  3. ChartTheme? theme,
  4. EdgeInsets? padding,
  5. String? title,
  6. String? subtitle,
  7. Widget? header,
  8. Widget? footer,
  9. bool useGlassmorphism = false,
  10. bool useNeumorphism = false,
  11. bool isLoading = false,
  12. bool isError = false,
  13. String? errorMessage,
  14. Widget? errorWidget,
  15. List<BoxShadow>? boxShadow,
})

Creates a chart container.

child is required and should be the chart widget to display. theme is optional and will be inferred from the Material theme if not provided. boxShadow is optional and allows custom shadow configuration. If not provided, default shadows will be used based on the selected visual style.

The container supports three visual styles:

  • Default: Clean card with subtle shadows
  • Glassmorphism: Frosted glass effect with backdrop blur
  • Neumorphism: Soft shadow effect with depth

Only one effect should be enabled at a time. If both useGlassmorphism and useNeumorphism are true, neumorphism takes precedence.

Example

ChartContainer(
  title: 'Sales',
  subtitle: 'Q1 2024',
  isLoading: isLoading,
  isError: hasError,
  errorMessage: errorMessage,
  boxShadow: [
    BoxShadow(
      color: Colors.black.withValues(alpha: 0.1),
      blurRadius: 10,
      offset: Offset(0, 4),
    ),
  ],
  child: MyChart(...),
)

Implementation

const ChartContainer({
  super.key,
  required this.child,
  this.theme,
  this.padding,
  this.title,
  this.subtitle,
  this.header,
  this.footer,
  this.useGlassmorphism = false,
  this.useNeumorphism = false,
  this.isLoading = false,
  this.isError = false,
  this.errorMessage,
  this.errorWidget,
  this.boxShadow,
});