Dart: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „Kategorie:Programmiersprache = Links = * https://codingwithjoe.com/dart-fundamentals-async-await“) |
(→Links) |
||
Zeile 3: | Zeile 3: | ||
= Links = | = Links = | ||
* https://codingwithjoe.com/dart-fundamentals-async-await | * https://codingwithjoe.com/dart-fundamentals-async-await | ||
= Class = | |||
<pre>class BaseLogger { | |||
int _errors = 0; | |||
void BaseLogger(){ | |||
} | |||
// abstract function: | |||
void log(string message); | |||
void error(string message){ | |||
_errors++; | |||
log('+++ ' + message); | |||
} | |||
class Logger extends BaseLogger { | |||
} | |||
... | |||
var logger = Logger('std.log'); | |||
</pre> | |||
== Interface == | |||
* Jede Klasse kann Interface sein. Dann muss jede Methode überschrieben werden | |||
<pre> | |||
class D implements A, B, C { | |||
@override | |||
void doIt(){ | |||
// ... | |||
} | |||
} | |||
</pre> | |||
= DateTime = | |||
<pre>var date = new DateTime.now(); | |||
</pre> | |||
= String = | |||
== Formatierung == | |||
<pre>import 'package:sprintf/sprintf.dart'; | |||
sprintf("%02d %s", [1, "Hi"]); | |||
print("${new DateTime.now().toString()}: $message\n"); | |||
</pre> |
Version vom 24. Dezember 2019, 21:24 Uhr
Links
Class
class BaseLogger { int _errors = 0; void BaseLogger(){ } // abstract function: void log(string message); void error(string message){ _errors++; log('+++ ' + message); } class Logger extends BaseLogger { } ... var logger = Logger('std.log');
Interface
- Jede Klasse kann Interface sein. Dann muss jede Methode überschrieben werden
class D implements A, B, C { @override void doIt(){ // ... } }
DateTime
var date = new DateTime.now();
String
Formatierung
import 'package:sprintf/sprintf.dart'; sprintf("%02d %s", [1, "Hi"]); print("${new DateTime.now().toString()}: $message\n");