GenderPickerWithImage constructor

GenderPickerWithImage({
  1. Key? key,
  2. TextStyle selectedGenderTextStyle = const TextStyle(fontSize: 19, color: Colors.redAccent, fontWeight: FontWeight.w600),
  3. TextStyle unSelectedGenderTextStyle = const TextStyle(fontSize: 19, color: Colors.black, fontWeight: FontWeight.w600),
  4. bool verticalAlignedText = false,
  5. Duration animationDuration = const Duration(milliseconds: 500),
  6. double opacityOfGradient = 0.6,
  7. EdgeInsetsGeometry padding = const EdgeInsets.all(10),
  8. bool isCircular = true,
  9. double size = 40.0,
  10. bool equallyAligned = true,
  11. Gender? selectedGender = Gender.Male,
  12. required ValueChanged<Gender?>? onChanged,
  13. LinearGradient linearGradient = const LinearGradient(colors: [Color(0xFF3271a8), Color(0xFF8b32a8)], tileMode: TileMode.clamp, begin: Alignment.bottomLeft, end: Alignment.topRight, stops: [0.0, 1.0]),
  14. bool showOtherGender = false,
  15. ImageProvider<Object> maleImage = const AssetImage("assets/images/male.png", package: 'gender_picker'),
  16. ImageProvider<Object> femaleImage = const AssetImage("assets/images/female.png", package: 'gender_picker'),
  17. ImageProvider<Object> otherGenderImage = const AssetImage("assets/images/other.png", package: 'gender_picker'),
  18. String maleText = "Male",
  19. String femaleText = "Female",
  20. String otherGenderText = "Other",
})

Implementation

GenderPickerWithImage({
  Key? key,
  // by default selected color of selected gender text
  this.selectedGenderTextStyle = const TextStyle(
    fontSize: 19,
    color: Colors.redAccent,
    fontWeight: FontWeight.w600,
  ),
  // by default un-selected color of selected gender text
  this.unSelectedGenderTextStyle = const TextStyle(
    fontSize: 19,
    color: Colors.black,
    fontWeight: FontWeight.w600,
  ),

  // bedefault verticallyaligned text is false to show in same row
  this.verticalAlignedText = false,

  // animation loading time by default set to [500 milliseconds]
  this.animationDuration = const Duration(milliseconds: 500),

  // by default gradient opacity set to 0.6
  this.opacityOfGradient = 0.6,
  // padding set to 10 from all side, you can also define yours
  this.padding = const EdgeInsets.all(10),

  // selection is in circular and can be in square as you needed
  this.isCircular = true,

  // default size of ImageIcon
  this.size = 40.0,

  // if alignment is true then everything will be in center
  this.equallyAligned = true,

  // to show selected Gender
  this.selectedGender = Gender.Male,

  // OnChanged is mandatory to implement, so ca change state of widget
  required this.onChanged,

  // by default gradient color
  this.linearGradient = const LinearGradient(
      colors: [Color(0xFF3271a8), Color(0xFF8b32a8)],
      tileMode: TileMode.clamp,
      begin: Alignment.bottomLeft,
      end: Alignment.topRight,
      stops: [0.0, 1.0]),
  this.showOtherGender = false,

  // Images asset can be network images,
  this.maleImage =
      const AssetImage("assets/images/male.png", package: 'gender_picker'),
  this.femaleImage =
      const AssetImage("assets/images/female.png", package: 'gender_picker'),
  this.otherGenderImage =
      const AssetImage("assets/images/other.png", package: 'gender_picker'),

  // by default text to show
  this.maleText = "Male",
  this.femaleText = "Female",
  this.otherGenderText = "Other",
}) : super(key: key);