buildRouteName method

String buildRouteName(
  1. String name,
  2. String value
)

Implementation

String buildRouteName(String name, String value) {
  if (!value.contains(':')) {
    return "  static const RouteName $name = '$value';";
  } else {
    List<String> paramList = value
        .split('/')
        .where((e) => e.contains(':'))
        .map((e) => e.replaceAll(':', ''))
        .toList();

    return "  static RouteName $name({${paramList.map((e) => 'String? $e').join(', ')}}) => ${paramList.map((e) => '$e == null').join(' && ')} ? '$value' : '${value.replaceAll(':', '\$')}';";
  }
}