Dart: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Links) |
(→Class) |
||
Zeile 5: | Zeile 5: | ||
= Class = | = Class = | ||
<pre>class BaseLogger { | <pre>abstract class BaseLogger { | ||
int _errors = 0; | int _errors = 0; | ||
void BaseLogger(){ | void BaseLogger(){ | ||
Zeile 30: | Zeile 30: | ||
} | } | ||
</pre> | </pre> | ||
= DateTime = | = DateTime = | ||
<pre>var date = new DateTime.now(); | <pre>var date = new DateTime.now(); |
Version vom 24. Dezember 2019, 21:33 Uhr
Links
Class
abstract 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");