mirror of
https://github.com/flutter/samples.git
synced 2025-11-09 06:18:49 +00:00
First pass at a Next Generation UI demo app. The UI needs work, feedback gratefully accepted. ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. <!-- Links --> [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/wiki/Chat [Contributors Guide]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md
38 lines
1022 B
Dart
38 lines
1022 B
Dart
// 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);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|