Skip to content

Instantly share code, notes, and snippets.

@nidev
Last active February 18, 2017 12:58
Show Gist options
  • Save nidev/07485eaef9bf79730a36d6eb2efd65a0 to your computer and use it in GitHub Desktop.
Save nidev/07485eaef9bf79730a36d6eb2efd65a0 to your computer and use it in GitHub Desktop.
Provide platform-dependent newline character. This function is not available in Platform class in dart:io package.
// This is also included in https://github.com/nidev/smallservlet
import "dart:io";
class PlatformUtil {
static final _NEWLINE_CRLF = "\r\n";
static final _NEWLINE_LF = "\n";
static String get newLine {
if (Platform.isWindows) {
// using \r\n
return _NEWLINE_CRLF;
}
else {
// using \n
return _NEWLINE_LF;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment