You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
samples/next_gen_ui_demo/lib/common/reactive_widget.dart

38 lines
1022 B

// Copyright 2023 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'ticking_builder.dart';
typedef ReactiveWidgetBuilder = Widget Function(
BuildContext context, double time, Size bounds);
/// ReactiveWidget forces repainting a subtree on
/// each frame for ambient animation.
class ReactiveWidget extends StatefulWidget {
const ReactiveWidget({
super.key,
required this.builder,
});
final ReactiveWidgetBuilder builder;
@override
State<ReactiveWidget> createState() => _ReactiveWidgetState();
}
class _ReactiveWidgetState extends State<ReactiveWidget> {
@override
Widget build(BuildContext context) {
return TickingBuilder(
builder: (_, time) {
return LayoutBuilder(
builder: (context, constraints) {
return widget.builder(context, time, constraints.biggest);
},
);
},
);
}
}