Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
64 lines
1.7 KiB
Dart
64 lines
1.7 KiB
Dart
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
/// Reports laid-out window coordinates after layout and movement.
|
|
class NativeBoundsReporter extends SingleChildRenderObjectWidget {
|
|
const NativeBoundsReporter({
|
|
super.key,
|
|
required this.onBounds,
|
|
required super.child,
|
|
});
|
|
final ValueChanged<Rect> onBounds;
|
|
@override
|
|
RenderObject createRenderObject(BuildContext context) =>
|
|
_RenderBoundsReporter(onBounds);
|
|
@override
|
|
void updateRenderObject(
|
|
BuildContext context,
|
|
covariant RenderObject renderObject,
|
|
) {
|
|
(renderObject as _RenderBoundsReporter).updateCallback(onBounds);
|
|
}
|
|
}
|
|
|
|
class _RenderBoundsReporter extends RenderProxyBox {
|
|
_RenderBoundsReporter(this.onBounds);
|
|
ValueChanged<Rect> onBounds;
|
|
void updateCallback(ValueChanged<Rect> callback) {
|
|
onBounds = callback;
|
|
_lastBounds = null;
|
|
_scheduleReport();
|
|
}
|
|
|
|
bool _scheduled = false;
|
|
Rect? _lastBounds;
|
|
void _scheduleReport() {
|
|
if (_scheduled || !attached) return;
|
|
_scheduled = true;
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
_scheduled = false;
|
|
if (!attached) return;
|
|
if (hasSize) {
|
|
final bounds = MatrixUtils.transformRect(
|
|
getTransformTo(null),
|
|
Offset.zero & size,
|
|
);
|
|
if (bounds != _lastBounds) {
|
|
_lastBounds = bounds;
|
|
onBounds(bounds);
|
|
}
|
|
}
|
|
// Ancestors can move retained layers without laying out or repainting
|
|
// this box. Observe the next frame without requesting an idle frame.
|
|
_scheduleReport();
|
|
});
|
|
}
|
|
|
|
@override
|
|
void attach(PipelineOwner owner) {
|
|
super.attach(owner);
|
|
_lastBounds = null;
|
|
_scheduleReport();
|
|
}
|
|
}
|