getScreenFileContent method

String getScreenFileContent(
  1. String screenName,
  2. String content,
  3. bool routeExist
)

Implementation

String getScreenFileContent(
    String screenName, String content, bool routeExist) {
  return content
      .replaceAll("<screen_name>", screenName)
      .replaceAll("<cubit_name>", screenName.cubitName)
      .replaceAll("<state_name>", screenName.stateName)
      .replaceAll("<screen_class_name>", screenName.screenClassName)
      .replaceAll("<screen_content>", screenName.screenContent)
      .replaceAll("<bloc_name>", screenName.blocName)
      .replaceAll(
          "<bloc_instance>",
          routeExist
              ? ""
              : "final ${screenName.blocName} bloc = ${screenName.blocName}();")
      .replaceAll("<bloc__instance>", routeExist ? "" : "bloc: bloc,")
      .replaceAll(
          "<cubit_instance>",
          routeExist
              ? ""
              : "final ${screenName.cubitName} cubit = ${screenName.cubitName}();")
      .replaceAll("<cubit__instance>", routeExist ? "" : "bloc: cubit,")
      .replaceAll("<close_bloc>", routeExist ? "" : "bloc.close();")
      .replaceAll("<close_cubit>", routeExist ? "" : "cubit.close();")
      .replaceAll(
          "<bloc_provider_instance>",
          routeExist
              ? "BlocProvider.of<${screenName.blocName}>(context)"
              : "bloc")
      .replaceAll(
          "<cubit_provider_instance>",
          routeExist
              ? "BlocProvider.of<${screenName.cubitName}>(context)"
              : "cubit")
      .replaceAppName;
}