Files
flame/lib/components/mixins/resizable.dart
Lukas Klingsbo 50f8ffce3b Vector2 extension
2020-09-20 17:30:58 +02:00

22 lines
772 B
Dart

import '../../vector2_extension.dart';
/// Useful mixin to add to your components if you want to hold a reference to the current screen size.
///
/// This mixin implements the resize method in order to hold an updated reference to the current screen [size].
/// Also, it updates its [children], if any.
class Resizable {
/// This is the current updated screen size.
Vector2 size;
/// Implementation provided by this mixin to the resize hook.
void resize(Vector2 size) {
this.size = size;
resizableChildren().where((e) => e != null).forEach((e) => e.resize(size));
}
/// Overwrite this to add children to this [Resizable].
///
/// If a [Resizable] has children, its children as resized as well.
Iterable<Resizable> resizableChildren() => [];
}