Skip to content

Instantly share code, notes, and snippets.

@maxim-saplin
Last active July 23, 2022 09:29
Show Gist options
  • Save maxim-saplin/554d0d8216d4b1da26f40d5247c38106 to your computer and use it in GitHub Desktop.
Save maxim-saplin/554d0d8216d4b1da26f40d5247c38106 to your computer and use it in GitHub Desktop.
import 'dart:math';
const String h = 'kjddHjblwoopwedlradljljlkdfefldlkfdog dgdfgdf';
abstract class A {
String getMessage() => 'A';
}
class B {
String getMessage() => 'B';
}
class P {
String getMessage() => 'P';
}
class AB extends P with A, B {}
class BA extends P with B, A {}
class CC implements P {
CC(this.message, {int howMuch = 3}) {
_val = List<int>.generate(howMuch, (index) => index + 1);
}
CC.four() : this('four', howMuch: 4);
final String message;
List<int>? _val;
List<int> get val => _val!;
@override
String getMessage() => message;
}
void main() {
String? result;
AB ab = new AB();
var ba = BA();
var cc = CC('CC', howMuch: 2);
result = ab.getMessage();
print(result);
print('ab type: ${ab.runtimeType}');
print("ab is A: " + (ab is A).toString());
print('ab is B: ${ab is B}');
print('ab is P: ${ab is P}');
result = ba.getMessage();
print(result);
print(cc.getMessage());
var s = '';
for (var i in cc.val) {
s += s.isEmpty ? i.toString() : ', $i' ;
}
print(s);
print(CC.four().getMessage());
var random = Random(1);
var x = <int>[1];
for (var i = 0; i < 11; i++) {
x.add(h.codeUnitAt(random.nextInt(40)));
}
print(String.fromCharCodes(x));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment