GradientText constructor

const GradientText({
  1. Key? key,
  2. Text? child,
  3. String text = '',
  4. Gradient gradient = const LinearGradient(colors: [Colors.red, Colors.blue], begin: Alignment.topLeft, end: Alignment.bottomRight),
  5. TextStyle textStyle = const TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: Colors.white),
  6. TextAlign textAlign = TextAlign.center,
})

Implementation

const GradientText({
  super.key,
  this.child,
  this.text = '',
  this.gradient = const LinearGradient(
    colors: [Colors.red, Colors.blue],
    begin: Alignment.topLeft,
    end: Alignment.bottomRight,
  ),
  this.textStyle = const TextStyle(
    fontSize: 24,
    fontWeight: FontWeight.bold,
    color: Colors.white, // 默认白色文本以便渐变显示
  ),
  this.textAlign = TextAlign.center,
});