form_require_text.dart 669 B

123456789101112131415161718192021222324252627282930
  1. import 'package:flutter/material.dart';
  2. /**
  3. * 表单中必填的文本描述,文本后加红色*标识
  4. * 使用富文本的方式实现
  5. */
  6. class FormRequireText extends StatelessWidget {
  7. final String text;
  8. FormRequireText({required this.text});
  9. @override
  10. Widget build(BuildContext context) {
  11. return RichText(
  12. text: TextSpan(
  13. style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w400, color: Colors.white),
  14. children: <TextSpan>[
  15. TextSpan(
  16. text: text,
  17. ),
  18. TextSpan(
  19. text: " *",
  20. style: TextStyle(color: Colors.red),
  21. ),
  22. ],
  23. ),
  24. );
  25. }
  26. }