text.dart 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. const FlowyText(
  10. this.title, {
  11. Key? key,
  12. this.overflow = TextOverflow.ellipsis,
  13. this.fontSize = 16,
  14. this.fontWeight = FontWeight.w500,
  15. }) : super(key: key);
  16. const FlowyText.medium(this.title, {Key? key, this.fontSize = 16, TextOverflow? overflow})
  17. : fontWeight = FontWeight.w500,
  18. overflow = overflow ?? TextOverflow.ellipsis,
  19. super(key: key);
  20. const FlowyText.regular(this.title, {Key? key, this.fontSize = 16, TextOverflow? overflow})
  21. : fontWeight = FontWeight.w400,
  22. overflow = overflow ?? TextOverflow.ellipsis,
  23. super(key: key);
  24. @override
  25. Widget build(BuildContext context) {
  26. final theme = context.watch<AppTheme>();
  27. return Text(title,
  28. overflow: overflow,
  29. softWrap: false,
  30. style: TextStyle(
  31. color: theme.shader1,
  32. fontWeight: fontWeight,
  33. fontSize: fontSize + 2,
  34. ));
  35. }
  36. }