entao_dutil 1.0.10 copy "entao_dutil: ^1.0.10" to clipboard
entao_dutil: ^1.0.10 copied to clipboard

Utils for dart.

Dart utils.

printX #

printX([positioned arguments], {named arguments})

void main() {
  test("printX", () {
    printX("abc");  // abc
    printX(1, 2);   // 1 2
    printX([1, 2, 3]);  // [1, 2, 3]
    printX(1, "a", "b", sep: ", "); // 1, a, b
    StringBuffer buf = StringBuffer();
    printX(1, "a", "b", sep: ", ", buf: buf );
    print(buf.toString()); // 1, a, b
  });
}

ini file #

void main() {
  String s = """
  host=google.com
  port=8080 ; this is comment
  [account]
  ; this is another comment
  user=entao
  type=admin
  [group]
  dept=dev
  """;
  IniFile ini = IniFile.parse(s);
  ini.put("dept", "test", section: "group");
  test("Ini file test", () {
    expect("google.com", ini.get("host"));
    expect("8080", ini.get("port"));
    expect("entao", ini.get("user", section: "account"));
    expect("admin", ini.get("type", section: "account"));
    expect("test", ini.get("dept", section: "group"));
  });
}

Config #

Like json, map/list/string/null are all the data type. " is not need to wrap string value. Use ':' or '=' seperate key and value. This is a map:

"""
{
host:g.com
port: 80
}
"""

OR

"{host:g.com; port:80}"

OR

"host:g.com; port:80"

This is a list:

"[1,2,3]"

OR

"[1; 2,3]"
void main() {
  String s = """
  host: google.com  
  port= 80  # this is comment
  options: [GET, POST, PUT; DELETE]
  # another comment.
  user: {
      name: entao; job: dev  #
      allow: [GET, POST]
  }
  """;
  EnMap em = EnConfig.parse(s).asMap!;
  test("config", () {
    expect("google.com", em["host"].toString());
    expect("80", em["port"].toString());
    expect("[GET, POST, PUT, DELETE]", em["options"].toString());
    expect("POST", em.getPathValue(key: "options.1").toString());
    expect("entao", em.getPathValue(key: "user.name").toString());
    expect("dev", em.getPathValue(key: "user.job").toString());
  });
}
0
likes
0
points
145
downloads

Publisher

unverified uploader

Weekly Downloads

Utils for dart.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, entao_lint, intl, os_detect, uuid

More

Packages that depend on entao_dutil