pascalCase property

String get pascalCase

Chuyển đổi chuỗi sang định dạng PascalCase. Ví dụ: "hello_world" -> "HelloWorld", "helloWorld" -> "HelloWorld"

Implementation

String get pascalCase {
  if (isEmpty) return this;

  // Chuyển đổi từ snake_case/kebab-case sang camelCase trước
  String tempCamel = replaceAllMapped(
    RegExp(r'[_-](.)'),
    (match) => match.group(1)!.toUpperCase(),
  );

  // Chuyển chữ cái đầu tiên thành hoa
  return tempCamel[0].toUpperCase() + tempCamel.substring(1);
}