text.dart 1.4 KB

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