基础库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 rivejä
722 B

  1. import 'package:zhiying_comm/util/empty_util.dart';
  2. import 'log/let_log.dart';
  3. class ParseUtil {
  4. ///
  5. /// String 转double
  6. ///
  7. static double stringParseDouble(final String val, {double defVal = 0.0}) {
  8. if (EmptyUtil.isEmpty(val)) return defVal;
  9. double rlt = defVal;
  10. try {
  11. rlt = double.parse(val);
  12. } catch (e, s) {
  13. Logger.warn(e, s);
  14. rlt = defVal;
  15. }
  16. return rlt;
  17. }
  18. ///
  19. /// string 转 int
  20. ///
  21. static int stringParseInt(final String val, {int defVal = 0}) {
  22. int rlt = defVal;
  23. if (!EmptyUtil.isEmpty(val)) {
  24. try {
  25. rlt = int.parse(val);
  26. } catch (e, s) {
  27. Logger.warn(e, s);
  28. rlt = defVal;
  29. }
  30. }
  31. return rlt;
  32. }
  33. }