Sonnat Project
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.

45 lines
1.1 KiB

  1. import 'dart:io';
  2. import 'package:flutter/foundation.dart';
  3. class Utilities {
  4. static String charInjector(
  5. String s,
  6. String char,
  7. int loopIndex, {
  8. bool loop = false,
  9. }) {
  10. var text = s.split('').reversed.join();
  11. if (!loop) {
  12. if (text.length < loopIndex) {
  13. return s;
  14. }
  15. var before = text.substring(0, loopIndex);
  16. var after = text.substring(loopIndex, text.length);
  17. return before + char + after;
  18. } else {
  19. if (loopIndex == 0) {
  20. return s;
  21. }
  22. var a = StringBuffer();
  23. for (var i = 0; i < text.length; i++) {
  24. if (i != 0 && i % loopIndex == 0) {
  25. a.write(char);
  26. }
  27. a.write(String.fromCharCode(text.runes.elementAt(i)));
  28. }
  29. return a.toString().split('').reversed.join();
  30. }
  31. }
  32. static bool get isWeb => kIsWeb;
  33. static bool get isAndroid => Platform.isAndroid;
  34. static bool get isIos => Platform.isIOS;
  35. static bool get isMobile => Platform.isAndroid || Platform.isIOS;
  36. static bool get isDesktop => Platform.isWindows || Platform.isMacOS || Platform.isMacOS;
  37. }