withContext method

String withContext(
  1. ComponentContext cContext, {
  2. List args = const [],
})

Implementation

String withContext(
  ComponentContext cContext, {
  List args = const [],
}) {
  if (startsWith('\$')) {
    final paths = substring(1).split('.');

    dynamic position = {...cContext};
    for (final path in paths) {
      position = position[path];

      if (position == null) {
        return this;
      }
    }

    for (final arg in args) {
      position = '$position'.replaceFirst('%s', '$arg');
    }

    return '$position';
  }

  return this;
}