1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 23:08:59 +00:00

Flutter 3.29 beta (#2571)

This commit is contained in:
Eric Windmill
2025-02-12 18:08:01 -05:00
committed by GitHub
parent d62c784789
commit 719fd72c38
685 changed files with 76244 additions and 53721 deletions

View File

@@ -63,8 +63,10 @@ class FragmentShadedState extends State<FragmentShaded>
parent: _dampenController,
curve: Curves.easeInOut,
);
_dampenAnimation =
Tween<double>(begin: 1.0, end: 0.0).animate(_dampenCurve);
_dampenAnimation = Tween<double>(
begin: 1.0,
end: 0.0,
).animate(_dampenCurve);
initializeFragmentProgramsAndBuilder();
}
@@ -76,8 +78,11 @@ class FragmentShadedState extends State<FragmentShaded>
}
setState(() {
builder = AnimatingSamplerBuilder(_controller, _dampenAnimation,
FragmentShaded._programCache[widget.shader]!.fragmentShader());
builder = AnimatingSamplerBuilder(
_controller,
_dampenAnimation,
FragmentShaded._programCache[widget.shader]!.fragmentShader(),
);
});
}
@@ -92,17 +97,11 @@ class FragmentShadedState extends State<FragmentShaded>
Widget build(BuildContext context) {
if (null == FragmentShaded._programCache[widget.shader]) {
setState(() {});
return const SizedBox(
width: 0,
height: 0,
);
return const SizedBox(width: 0, height: 0);
}
return Transform.scale(
scale: 0.5,
child: ShaderSamplerBuilder(
builder,
child: widget.child,
),
child: ShaderSamplerBuilder(builder, child: widget.child),
);
}
@@ -113,7 +112,10 @@ class FragmentShadedState extends State<FragmentShaded>
class AnimatingSamplerBuilder extends SamplerBuilder {
AnimatingSamplerBuilder(
this.animation, this.dampenAnimation, this.fragmentShader) {
this.animation,
this.dampenAnimation,
this.fragmentShader,
) {
animation.addListener(notifyListeners);
dampenAnimation.addListener(notifyListeners);
}
@@ -152,11 +154,7 @@ class ShaderSamplerBuilder extends StatelessWidget {
@override
Widget build(BuildContext context) {
return RepaintBoundary(
child: _ShaderSamplerImpl(
builder,
child: child,
));
return RepaintBoundary(child: _ShaderSamplerImpl(builder, child: child));
}
}
@@ -175,7 +173,9 @@ class _ShaderSamplerImpl extends SingleChildRenderObjectWidget {
@override
void updateRenderObject(
BuildContext context, covariant RenderObject renderObject) {
BuildContext context,
covariant RenderObject renderObject,
) {
(renderObject as _RenderShaderSamplerBuilderWidget)
..devicePixelRatio = MediaQuery.of(context).devicePixelRatio
..builder = builder;
@@ -189,8 +189,8 @@ class _RenderShaderSamplerBuilderWidget extends RenderProxyBox {
_RenderShaderSamplerBuilderWidget({
required double devicePixelRatio,
required SamplerBuilder builder,
}) : _devicePixelRatio = devicePixelRatio,
_builder = builder;
}) : _devicePixelRatio = devicePixelRatio,
_builder = builder;
/// The device pixel ratio used to create the child image.
double get devicePixelRatio => _devicePixelRatio;
@@ -250,16 +250,20 @@ class _RenderShaderSamplerBuilderWidget extends RenderProxyBox {
// children from this layer.
ui.Image? _paintAndDetachToImage() {
final OffsetLayer offsetLayer = OffsetLayer();
final PaintingContext context =
PaintingContext(offsetLayer, Offset.zero & size);
final PaintingContext context = PaintingContext(
offsetLayer,
Offset.zero & size,
);
super.paint(context, Offset.zero);
// This ignore is here because this method is protected by the `PaintingContext`. Adding a new
// method that performs the work of `_paintAndDetachToImage` would avoid the need for this, but
// that would conflict with our goals of minimizing painting context.
// ignore: invalid_use_of_protected_member
context.stopRecordingIfNeeded();
final ui.Image image = offsetLayer.toImageSync(Offset.zero & size,
pixelRatio: devicePixelRatio);
final ui.Image image = offsetLayer.toImageSync(
Offset.zero & size,
pixelRatio: devicePixelRatio,
);
offsetLayer.dispose();
return image;
}

View File

@@ -73,16 +73,16 @@ class _LightboxedPanelState extends State<LightboxedPanel> {
return [
Column(
children: [
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
TextButton(
onPressed: handleDismiss,
style: ButtonStyles.style(),
child: Text(
'OK',
style: TextStyles.bodyStyle()
.copyWith(color: Colors.white, height: 1.2),
style: TextStyles.bodyStyle().copyWith(
color: Colors.white,
height: 1.2,
),
),
),
],
@@ -111,10 +111,11 @@ class _LightboxedPanelState extends State<LightboxedPanel> {
),
boxShadow: const [
BoxShadow(
color: Color.fromARGB(30, 0, 0, 0),
offset: Offset.zero,
blurRadius: 4.0,
spreadRadius: 2.0),
color: Color.fromARGB(30, 0, 0, 0),
offset: Offset.zero,
blurRadius: 4.0,
spreadRadius: 2.0,
),
],
borderRadius: const BorderRadius.all(Radius.circular(10.0)),
),
@@ -123,7 +124,8 @@ class _LightboxedPanelState extends State<LightboxedPanel> {
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: widget.content +
children:
widget.content +
(widget.buildButton ? buttonComponents() : []),
),
),
@@ -133,9 +135,6 @@ class _LightboxedPanelState extends State<LightboxedPanel> {
),
);
}
return const SizedBox(
width: 0,
height: 0,
);
return const SizedBox(width: 0, height: 0);
}
}

View File

@@ -55,17 +55,14 @@ class RotatorPuzzleState extends State<RotatorPuzzle>
);
late final CurvedAnimation animationCurve = CurvedAnimation(
parent: animationController,
curve: const Interval(
0.2,
0.45,
curve: Curves.easeOut,
),
curve: const Interval(0.2, 0.45, curve: Curves.easeOut),
);
late Animation<double> opacAnimation =
Tween<double>(begin: 0.4, end: 1.0).animate(animationCurve)
..addListener(() {
setState(() {});
});
late Animation<double> opacAnimation = Tween<double>(
begin: 0.4,
end: 1.0,
).animate(animationCurve)..addListener(() {
setState(() {});
});
List<GlobalKey<RotatorPuzzleTileState>> tileKeys = [];
GlobalKey<FragmentShadedState> shadedWidgetStackHackStateKey = GlobalKey();
@@ -129,14 +126,16 @@ class RotatorPuzzleState extends State<RotatorPuzzle>
}
if (status == AnimationStatus.completed) {
Future.delayed(
const Duration(milliseconds: FragmentShaded.dampenDuration + 250),
() {
widget.pageConfig.pageController.nextPage(
duration:
const Duration(milliseconds: PagesFlow.pageScrollDuration),
curve: Curves.easeOut,
);
});
const Duration(milliseconds: FragmentShaded.dampenDuration + 250),
() {
widget.pageConfig.pageController.nextPage(
duration: const Duration(
milliseconds: PagesFlow.pageScrollDuration,
),
curve: Curves.easeOut,
);
},
);
}
});
animationController.forward();
@@ -201,7 +200,8 @@ class RotatorPuzzleState extends State<RotatorPuzzle>
child: Opacity(
opacity: opacAnimation.value,
child: Stack(
children: <Widget>[
children:
<Widget>[
Positioned(
left: -9999,
top: -9999,
@@ -287,9 +287,7 @@ class RotatorPuzzleTileState extends State<RotatorPuzzleTile>
Duration touchedOpacDur = const Duration(milliseconds: 50);
late final AnimationController animationController = AnimationController(
vsync: this,
duration: const Duration(
milliseconds: 100,
),
duration: const Duration(milliseconds: 100),
);
late final CurvedAnimation animationCurve = CurvedAnimation(
parent: animationController,
@@ -317,9 +315,12 @@ class RotatorPuzzleTileState extends State<RotatorPuzzleTile>
}
});
// end hack ------------------------------
List<double> coords =
widget.parentState.tileCoords(row: widget.row, col: widget.col);
double zeroPoint = widget.parentState.widget.pageConfig.puzzleSize * .5 -
List<double> coords = widget.parentState.tileCoords(
row: widget.row,
col: widget.col,
);
double zeroPoint =
widget.parentState.widget.pageConfig.puzzleSize * .5 -
widget.parentState.tileSize() * 0.5;
return Stack(
@@ -386,7 +387,8 @@ class RotatorPuzzleTileState extends State<RotatorPuzzleTile>
},
child: DecoratedBox(
decoration: const BoxDecoration(
color: Color.fromARGB(120, 0, 0, 0)),
color: Color.fromARGB(120, 0, 0, 0),
),
child: SizedBox(
width: widget.parentState.tileSize(),
height: widget.parentState.tileSize(),
@@ -420,10 +422,9 @@ class RotatorPuzzleTileState extends State<RotatorPuzzleTile>
animation = Tween<double>(
begin: oldStatus * pi * 0.5,
end: currentStatus() * pi * 0.5,
).animate(animationController)
..addListener(() {
setState(() {});
});
).animate(animationController)..addListener(() {
setState(() {});
});
animationController.reset();
animationController.forward();
}

View File

@@ -19,9 +19,7 @@ import '../components/components.dart';
// an enumeration of variable font axes at https://fonts.google.com/variablefonts
class WonkyAnimPalette {
const WonkyAnimPalette({
Key? key,
});
const WonkyAnimPalette({Key? key});
static const Curve defaultCurve = Curves.easeInOut;
// basic (settings unrelated to variable font)

View File

@@ -35,18 +35,29 @@ class WonkyCharState extends State<WonkyChar>
final List<String> _fvAxes = [];
// default curve and animations in case user sets nothing for them
late final defaultCurve = CurvedAnimation(
parent: _animController,
curve: const Interval(0, 1, curve: Curves.linear));
late Animation _scaleAnimation =
Tween<double>(begin: 1, end: 1).animate(defaultCurve);
late Animation _offsetXAnimation =
Tween<double>(begin: 0, end: 0).animate(defaultCurve);
late Animation _offsetYAnimation =
Tween<double>(begin: 0, end: 0).animate(defaultCurve);
late Animation _rotationAnimation =
Tween<double>(begin: 0, end: 0).animate(defaultCurve);
late Animation _colorAnimation =
ColorTween(begin: Colors.black, end: Colors.black).animate(defaultCurve);
parent: _animController,
curve: const Interval(0, 1, curve: Curves.linear),
);
late Animation _scaleAnimation = Tween<double>(
begin: 1,
end: 1,
).animate(defaultCurve);
late Animation _offsetXAnimation = Tween<double>(
begin: 0,
end: 0,
).animate(defaultCurve);
late Animation _offsetYAnimation = Tween<double>(
begin: 0,
end: 0,
).animate(defaultCurve);
late Animation _rotationAnimation = Tween<double>(
begin: 0,
end: 0,
).animate(defaultCurve);
late Animation _colorAnimation = ColorTween(
begin: Colors.black,
end: Colors.black,
).animate(defaultCurve);
@override
void initState() {
@@ -80,15 +91,22 @@ class WonkyCharState extends State<WonkyChar>
Widget build(BuildContext context) {
List<ui.FontVariation> fontVariations = [];
for (int i = 0; i < _fvAxes.length; i++) {
fontVariations
.add(ui.FontVariation(_fvAxes[i], _fvAnimations[i].value as double));
fontVariations.add(
ui.FontVariation(_fvAxes[i], _fvAnimations[i].value as double),
);
}
return Transform(
alignment: Alignment.center,
transform: Matrix4.translationValues(_offsetXAnimation.value as double,
_offsetYAnimation.value as double, 0)
..scale(_scaleAnimation.value)
..rotateZ(widget.baseRotation + (_rotationAnimation.value as double)),
transform:
Matrix4.translationValues(
_offsetXAnimation.value as double,
_offsetYAnimation.value as double,
0,
)
..scale(_scaleAnimation.value)
..rotateZ(
widget.baseRotation + (_rotationAnimation.value as double),
),
child: IgnorePointer(
child: Text(
widget.text,
@@ -117,14 +135,14 @@ class WonkyCharState extends State<WonkyChar>
late Animation animation;
if (s.property == 'color') {
animation = ColorTween(
begin: s.fromTo.fromValue() as Color?,
end: s.fromTo.toValue() as Color?)
.animate(curve);
begin: s.fromTo.fromValue() as Color?,
end: s.fromTo.toValue() as Color?,
).animate(curve);
} else {
animation = Tween<double>(
begin: s.fromTo.fromValue() as double,
end: s.fromTo.toValue() as double)
.animate(curve);
begin: s.fromTo.fromValue() as double,
end: s.fromTo.toValue() as double,
).animate(curve);
}
if (s.type == 'fv') {
_fvAxes.add(s.property);
@@ -155,7 +173,8 @@ class WonkyCharState extends State<WonkyChar>
{
if (kDebugMode) {
print(
'**ERROR** unrecognized property to animate: ${s.property}');
'**ERROR** unrecognized property to animate: ${s.property}',
);
}
}
}