mirror of
https://github.com/flutter/samples.git
synced 2026-05-13 10:27:09 +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:
28
next_gen_ui_demo/lib/common/shader_painter.dart
Normal file
28
next_gen_ui_demo/lib/common/shader_painter.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ShaderPainter extends CustomPainter {
|
||||
ShaderPainter(this.shader, {this.update});
|
||||
|
||||
final FragmentShader shader;
|
||||
final void Function(FragmentShader, Size)? update;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
update?.call(shader, size);
|
||||
canvas.drawRect(
|
||||
Rect.fromLTWH(0, 0, size.width, size.height),
|
||||
Paint()..shader = shader,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant ShaderPainter oldDelegate) {
|
||||
return oldDelegate.shader != shader || oldDelegate.update != update;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user