1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-14 02:47:42 +00:00

Next Gen UI demo (#1778)

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
This commit is contained in:
Brett Morgan
2023-05-17 12:45:47 +10:00
committed by GitHub
parent e2ada7a698
commit aec29f869b
187 changed files with 11174 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
// 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 'package:flutter/scheduler.dart';
/// TickingBuilder is for ambient animation to be run
/// on each frame.
class TickingBuilder extends StatefulWidget {
const TickingBuilder({super.key, required this.builder});
final Widget Function(BuildContext context, double time) builder;
@override
State<TickingBuilder> createState() => _TickingBuilderState();
}
class _TickingBuilderState extends State<TickingBuilder>
with SingleTickerProviderStateMixin {
late final Ticker _ticker;
double _time = 0.0;
@override
void initState() {
super.initState();
_ticker = createTicker(_handleTick)..start();
}
@override
void dispose() {
_ticker.dispose();
super.dispose();
}
void _handleTick(Duration elapsed) {
setState(() => _time = elapsed.inMilliseconds.toDouble() / 1000.0);
}
@override
Widget build(BuildContext context) => widget.builder.call(context, _time);
}