Profile constructor

Profile({
  1. Key? key,
  2. required double? radius,
  3. required String? text,
  4. OnPickerChange? onPickerChange,
  5. OnPickerChangeWeb? onPickerChangeWeb,
  6. OnPickerCompleted? onPickerCompleted,
  7. OnFilePickerCompleted? onFilePickerCompleted,
  8. OnBytesPickerCompleted? onBytesPickerCompleted,
  9. String? image,
  10. String? imageNetwork,
  11. Gradient? gradientBackgroundColor,
  12. double elevation = 0,
  13. Color? shadowColor = Colors.black,
  14. bool isBorderAvatar = false,
  15. Color? backgroundColor,
  16. BottomSheetStyles? bottomSheetStyles,
  17. Gradient? gradientWidthBorder = const LinearGradient(colors: [Colors.blue, Colors.deepPurple]),
  18. Color iconColor = Colors.black,
  19. double widthBorder = 5.0,
  20. Color backgroundColorCamera = Colors.white,
  21. IconData? icon = Icons.camera,
  22. OptionsCrop? optionsCrop,
  23. OptionsCropWindMacLinux? optionsCropWindMacLinux,
  24. TextStyle? style = const TextStyle(fontSize: 25, color: Colors.white, fontWeight: FontWeight.bold),
  25. bool randomColor = true,
  26. bool randomGradient = false,
  27. bool useMaterialColorForGradient = true,
  28. bool mixColorForGradient = false,
  29. Widget? child,
})

Implementation

Profile({
  super.key,
  required this.radius,
  required this.text,
  this.onPickerChange,
  this.onPickerChangeWeb,
  this.onPickerCompleted,
  this.onFilePickerCompleted,
  this.onBytesPickerCompleted,
  this.image,
  this.imageNetwork,
  this.gradientBackgroundColor,
  this.elevation = 0,
  this.shadowColor = Colors.black,
  this.isBorderAvatar = false,
  this.backgroundColor,
  this.bottomSheetStyles,
  this.gradientWidthBorder = const LinearGradient(
    colors: [Colors.blue, Colors.deepPurple],
  ),
  this.iconColor = Colors.black,
  this.widthBorder = 5.0,
  this.backgroundColorCamera = Colors.white,
  this.icon = Icons.camera,
  this.optionsCrop,
  this.optionsCropWindMacLinux,
  this.style = const TextStyle(
    fontSize: 25,
    color: Colors.white,
    fontWeight: FontWeight.bold,
  ),
  bool randomColor = true,
  bool randomGradient = false,
  this.useMaterialColorForGradient = true,
  this.mixColorForGradient = false,
  this.child,
}) {
  // Automatically disable random flags if specific colors are provided
  if (backgroundColor != null || gradientBackgroundColor != null) {
    randomColor = false;
    randomGradient = false;
  }

  if (randomColor && randomGradient) {
    throw Exception(
      'Both randomColor and randomGradient cannot be true simultaneously.',
    );
  }

  if (randomColor) {
    backgroundColor = TextToColor.toColor(text);
  } else if (randomGradient) {
    gradientBackgroundColor = GradientRandomTools.getGradient(
      text.toString(),
      material: useMaterialColorForGradient,
      dynamicMix: mixColorForGradient,
    );
  } else if (backgroundColor == null && gradientBackgroundColor == null) {
    // Default to green if no color is provided and random is off
    backgroundColor = Colors.green;
  }
}