compileString function Compile

  1. @Deprecated("Use compileStringToResult() instead.")
String compileString(
  1. String source, {
  2. Syntax? syntax,
  3. bool color = false,
  4. Logger? logger,
  5. Iterable<Importer>? importers,
  6. PackageConfig? packageConfig,
  7. Iterable<String>? loadPaths,
  8. Iterable<Callable>? functions,
  9. OutputStyle? style,
  10. Importer? importer,
  11. Object? url,
  12. bool quietDeps = false,
  13. bool verbose = false,
  14. @Deprecated("Use CompileResult.sourceMap from compileStringToResult() instead.") void sourceMap(
    1. SingleMapping map
    )?,
  15. bool charset = true,
  16. @Deprecated("Use syntax instead.") bool indented = false,
})

Like compileStringToResult, but returns CompileResult.css rather than returning CompileResult directly.

If sourceMap is passed, it's passed a SingleMapping that indicates which sections of the source file(s) correspond to which in the resulting CSS. It's called immediately before this method returns, and only if compilation succeeds. Note that SingleMapping.targetUrl will always be null. Users using the SingleMapping API should be sure to add the source_maps package to their pubspec.

This parameter is meant to be used as an out parameter, so that users who want access to the source map can get it. For example:

SingleMapping sourceMap;
var css = compileString(sass, sourceMap: (map) => sourceMap = map);

Implementation

@Deprecated("Use compileStringToResult() instead.")
String compileString(String source,
    {Syntax? syntax,
    bool color = false,
    Logger? logger,
    Iterable<Importer>? importers,
    PackageConfig? packageConfig,
    Iterable<String>? loadPaths,
    Iterable<Callable>? functions,
    OutputStyle? style,
    Importer? importer,
    Object? url,
    bool quietDeps = false,
    bool verbose = false,
    @Deprecated(
        "Use CompileResult.sourceMap from compileStringToResult() instead.")
    void sourceMap(SingleMapping map)?,
    bool charset = true,
    @Deprecated("Use syntax instead.") bool indented = false}) {
  var result = compileStringToResult(source,
      syntax: syntax ?? (indented ? Syntax.sass : Syntax.scss),
      logger: logger,
      importers: importers,
      packageConfig: packageConfig,
      loadPaths: loadPaths,
      functions: functions,
      style: style,
      importer: importer,
      url: url,
      quietDeps: quietDeps,
      verbose: verbose,
      sourceMap: sourceMap != null,
      charset: charset);
  result.sourceMap.andThen(sourceMap);
  return result.css;
}