Files
flame/lib/components/resizable.dart
2019-03-23 15:02:17 -03:00

22 lines
723 B
Dart

import 'dart:ui';
/// 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.
Size size;
/// Implementation provided by this mixin to the resize hook.
void resize(Size size) {
this.size = size;
children().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.
List<Resizable> children() => [];
}