mirror of
https://github.com/flutter/samples.git
synced 2026-05-14 02:47:42 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -52,21 +52,21 @@ class ConfettiPainter extends CustomPainter {
|
||||
|
||||
final UnmodifiableListView<Color> colors;
|
||||
|
||||
ConfettiPainter(
|
||||
{required Listenable animation, required Iterable<Color> colors})
|
||||
: colors = UnmodifiableListView(colors),
|
||||
super(repaint: animation);
|
||||
ConfettiPainter({
|
||||
required Listenable animation,
|
||||
required Iterable<Color> colors,
|
||||
}) : colors = UnmodifiableListView(colors),
|
||||
super(repaint: animation);
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
if (_size == null) {
|
||||
// First time we have a size.
|
||||
_snippings = List.generate(
|
||||
snippingsCount,
|
||||
(i) => _PaperSnipping(
|
||||
frontColor: colors[i % colors.length],
|
||||
bounds: size,
|
||||
));
|
||||
snippingsCount,
|
||||
(i) =>
|
||||
_PaperSnipping(frontColor: colors[i % colors.length], bounds: size),
|
||||
);
|
||||
}
|
||||
|
||||
final didResize = _size != null && _size != size;
|
||||
@@ -97,10 +97,7 @@ class _ConfettiState extends State<Confetti>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomPaint(
|
||||
painter: ConfettiPainter(
|
||||
colors: widget.colors,
|
||||
animation: _controller,
|
||||
),
|
||||
painter: ConfettiPainter(colors: widget.colors, animation: _controller),
|
||||
willChange: true,
|
||||
child: const SizedBox.expand(),
|
||||
);
|
||||
@@ -181,10 +178,8 @@ class _PaperSnipping {
|
||||
|
||||
final paint = Paint()..style = PaintingStyle.fill;
|
||||
|
||||
_PaperSnipping({
|
||||
required this.frontColor,
|
||||
required Size bounds,
|
||||
}) : _bounds = bounds;
|
||||
_PaperSnipping({required this.frontColor, required Size bounds})
|
||||
: _bounds = bounds;
|
||||
|
||||
void draw(Canvas canvas) {
|
||||
if (cosA > 0) {
|
||||
@@ -193,16 +188,17 @@ class _PaperSnipping {
|
||||
paint.color = backColor;
|
||||
}
|
||||
|
||||
final path = Path()
|
||||
..addPolygon(
|
||||
List.generate(
|
||||
final path =
|
||||
Path()..addPolygon(
|
||||
List.generate(
|
||||
4,
|
||||
(index) => Offset(
|
||||
position.x + corners[index].x * size,
|
||||
position.y + corners[index].y * size * cosA,
|
||||
)),
|
||||
true,
|
||||
);
|
||||
position.x + corners[index].x * size,
|
||||
position.y + corners[index].y * size * cosA,
|
||||
),
|
||||
),
|
||||
true,
|
||||
);
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,7 @@ CustomTransitionPage<T> buildMyTransition<T>({
|
||||
return CustomTransitionPage<T>(
|
||||
child: child,
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
return _MyReveal(
|
||||
animation: animation,
|
||||
color: color,
|
||||
child: child,
|
||||
);
|
||||
return _MyReveal(animation: animation, color: color, child: child);
|
||||
},
|
||||
key: key,
|
||||
name: name,
|
||||
@@ -90,9 +86,7 @@ class _MyRevealState extends State<_MyReveal> {
|
||||
reverseCurve: Curves.easeOutCubic,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
color: widget.color,
|
||||
),
|
||||
child: Container(color: widget.color),
|
||||
),
|
||||
AnimatedOpacity(
|
||||
opacity: _finished ? 1 : 0,
|
||||
|
||||
@@ -46,10 +46,7 @@ class ResponsiveScreen extends StatelessWidget {
|
||||
children: [
|
||||
SafeArea(
|
||||
bottom: false,
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: topMessageArea,
|
||||
),
|
||||
child: Padding(padding: padding, child: topMessageArea),
|
||||
),
|
||||
Expanded(
|
||||
flex: (mainAreaProminence * 100).round(),
|
||||
@@ -63,10 +60,7 @@ class ResponsiveScreen extends StatelessWidget {
|
||||
SafeArea(
|
||||
top: false,
|
||||
maintainBottomViewPadding: true,
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: rectangularMenuArea,
|
||||
),
|
||||
child: Padding(padding: padding, child: rectangularMenuArea),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -94,10 +88,7 @@ class ResponsiveScreen extends StatelessWidget {
|
||||
bottom: false,
|
||||
left: false,
|
||||
maintainBottomViewPadding: true,
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: topMessageArea,
|
||||
),
|
||||
child: Padding(padding: padding, child: topMessageArea),
|
||||
),
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
@@ -112,7 +103,7 @@ class ResponsiveScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -8,11 +8,10 @@ import 'package:flutter/material.dart';
|
||||
/// with global key [scaffoldMessengerKey] is anywhere in the widget tree.
|
||||
void showSnackBar(String message) {
|
||||
final messenger = scaffoldMessengerKey.currentState;
|
||||
messenger?.showSnackBar(
|
||||
SnackBar(content: Text(message)),
|
||||
);
|
||||
messenger?.showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
|
||||
/// Use this when creating [MaterialApp] if you want [showSnackBar] to work.
|
||||
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =
|
||||
GlobalKey(debugLabel: 'scaffoldMessengerKey');
|
||||
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey = GlobalKey(
|
||||
debugLabel: 'scaffoldMessengerKey',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user