text.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:flowy_infra/theme.dart';
  2. import 'package:flutter/widgets.dart';
  3. import 'package:provider/provider.dart';
  4. class FlowyText extends StatelessWidget {
  5. final String title;
  6. final TextOverflow overflow;
  7. final double fontSize;
  8. final FontWeight fontWeight;
  9. final Color? color;
  10. const FlowyText(
  11. this.title, {
  12. Key? key,
  13. this.overflow = TextOverflow.ellipsis,
  14. this.fontSize = 16,
  15. this.fontWeight = FontWeight.w400,
  16. this.color,
  17. }) : super(key: key);
  18. const FlowyText.semibold(this.title, {Key? key, this.fontSize = 16, TextOverflow? overflow, this.color})
  19. : fontWeight = FontWeight.w600,
  20. overflow = overflow ?? TextOverflow.ellipsis,
  21. super(key: key);
  22. const FlowyText.medium(this.title, {Key? key, this.fontSize = 16, TextOverflow? overflow, this.color})
  23. : fontWeight = FontWeight.w500,
  24. overflow = overflow ?? TextOverflow.ellipsis,
  25. super(key: key);
  26. const FlowyText.regular(this.title, {Key? key, this.fontSize = 16, TextOverflow? overflow, this.color})
  27. : fontWeight = FontWeight.w400,
  28. overflow = overflow ?? TextOverflow.ellipsis,
  29. super(key: key);
  30. @override
  31. Widget build(BuildContext context) {
  32. final theme = context.watch<AppTheme>();
  33. final textColor = color ?? theme.shader1;
  34. return Text(title,
  35. overflow: overflow,
  36. softWrap: false,
  37. style: TextStyle(
  38. color: textColor,
  39. fontWeight: fontWeight,
  40. fontSize: fontSize + 2,
  41. ));
  42. }
  43. }