Skip to content

Instantly share code, notes, and snippets.

@azaslavsky
Last active April 13, 2022 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azaslavsky/2c6389b24899d5464f51a7fc5600bf85 to your computer and use it in GitHub Desktop.
Save azaslavsky/2c6389b24899d5464f51a7fc5600bf85 to your computer and use it in GitHub Desktop.
Const constructor
import 'dart:typed_data';
const BAR = Foo(
a: true,
b: 1234,
c: C(
$unknownData: null,
d: "abcd",
));
void main() {
print ("a: ${BAR.a}");
print ("b: ${BAR.b}");
print ("c.d: ${BAR.c.d}");
}
// Everything below is existing fildgen output.
class Foo {
const Foo({
required this.a,
required this.b,
required this.c,
});
final bool a;
final int b;
final C c;
}
class C {
const C({
this.$unknownData,
this.d,
});
@override
final Map<int, UnknownRawData>? $unknownData;
final String? d;
}
class UnknownRawData {
UnknownRawData(this.data, this.handles);
Uint8List data;
List<int> handles;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment