
import 'package:flutter/material.dart';

class CustomText extends StatelessWidget {
  final FontWeight? weight;
  final Color? color;
  final double? size;
  final String text;
  final int? maxLines;
  final TextOverflow? overflow;

  const CustomText({
    Key? key,
    this.weight,
    this.color,
    this.size,
    required this.text,
    this.maxLines,
    this.overflow,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Text(
      text,
      style: TextStyle(
        fontWeight: FontWeight.lerp(
          weight,
          FontWeight.values[
          (FontWeight.values.indexOf(weight??FontWeight.w400) + 1)
              .clamp(0, FontWeight.values.length - 1) // prevent overflow
          ],
          0.5, // t: pick between 0.0 and 1.0
        ),
        color: color,
        fontSize: size,
      ),
      maxLines: maxLines,
      overflow: overflow,
    );
  }
}

