Debian Codegraph @

examples/prism-dart.html

raw symbols SCIP
1 <h2>Comments</h2>
2 <pre><code>// Single line comment
3 /// Documentation single line comment
4 /* Block comment
5 on several lines */
6 /** Multi-line
7 doc comment */</code></pre>
8
9 <h2>Annotations</h2>
10 <pre><code>@todo('seth', 'make this do something')
11 @deprecated // Metadata; makes Dart Editor warn about using activate().</code></pre>
12
13 <h2>Numbers</h2>
14 <pre><code>var x = 1;
15 var hex = 0xDEADBEEF;
16 var bigInt = 346534658346524376592384765923749587398457294759347029438709349347;
17 var y = 1.1;
18 var exponents = 1.42e5;
19 </code></pre>
20
21 <h2>Strings</h2>
22 <pre><code>var s1 = 'Single quotes work well for string literals.';
23 var s2 = "Double quotes work just as well.";
24 var s3 = 'It\'s easy to escape the string delimiter.';
25 var s4 = "It's even easier to just use the other string delimiter.";
26 var s1 = '''
27 You can create
28 multi-line strings like this one.
29 ''';
30 var s2 = """This is also a
31 multi-line string.""";
32 var s = r"In a raw string, even \n isn't special.";</code></pre>
33
34 <h2>Full example</h2>
35 <pre><code>class Logger {
36 final String name;
37 bool mute = false;
38
39 // _cache is library-private, thanks to the _ in front of its name.
40 static final Map&lt;String, Logger> _cache = &lt;String, Logger>{};
41
42 factory Logger(String name) {
43 if (_cache.containsKey(name)) {
44 return _cache[name];
45 } else {
46 final logger = new Logger._internal(name);
47 _cache[name] = logger;
48 return logger;
49 }
50 }
51
52 Logger._internal(this.name);
53
54 void log(String msg) {
55 if (!mute) {
56 print(msg);
57 }
58 }
59 }</code></pre>