mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -57,9 +57,9 @@ class _PerformancePageState extends State<PerformancePage> {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(elevation: 8.0),
|
||||
onPressed: switch (snapshot.connectionState) {
|
||||
ConnectionState.done => () =>
|
||||
handleComputeOnMain(context),
|
||||
_ => null
|
||||
ConnectionState.done =>
|
||||
() => handleComputeOnMain(context),
|
||||
_ => null,
|
||||
},
|
||||
child: const Text('Compute on Main'),
|
||||
);
|
||||
@@ -69,13 +69,14 @@ class _PerformancePageState extends State<PerformancePage> {
|
||||
future: computeFuture,
|
||||
builder: (context, snapshot) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(elevation: 8.0),
|
||||
onPressed: switch (snapshot.connectionState) {
|
||||
ConnectionState.done => () =>
|
||||
handleComputeOnSecondary(context),
|
||||
_ => null
|
||||
},
|
||||
child: const Text('Compute on Secondary'));
|
||||
style: ElevatedButton.styleFrom(elevation: 8.0),
|
||||
onPressed: switch (snapshot.connectionState) {
|
||||
ConnectionState.done =>
|
||||
() => handleComputeOnSecondary(context),
|
||||
_ => null,
|
||||
},
|
||||
child: const Text('Compute on Secondary'),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -87,14 +88,12 @@ class _PerformancePageState extends State<PerformancePage> {
|
||||
}
|
||||
|
||||
void handleComputeOnMain(BuildContext context) {
|
||||
var future = computeOnMainIsolate()
|
||||
..then((_) {
|
||||
var snackBar = const SnackBar(
|
||||
content: Text('Main Isolate Done!'),
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
});
|
||||
var future =
|
||||
computeOnMainIsolate()..then((_) {
|
||||
var snackBar = const SnackBar(content: Text('Main Isolate Done!'));
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
});
|
||||
|
||||
setState(() {
|
||||
computeFuture = future;
|
||||
@@ -102,14 +101,14 @@ class _PerformancePageState extends State<PerformancePage> {
|
||||
}
|
||||
|
||||
void handleComputeOnSecondary(BuildContext context) {
|
||||
var future = computeOnSecondaryIsolate()
|
||||
..then((_) {
|
||||
var snackBar = const SnackBar(
|
||||
content: Text('Secondary Isolate Done!'),
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
});
|
||||
var future =
|
||||
computeOnSecondaryIsolate()..then((_) {
|
||||
var snackBar = const SnackBar(
|
||||
content: Text('Secondary Isolate Done!'),
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
});
|
||||
|
||||
setState(() {
|
||||
computeFuture = future;
|
||||
@@ -146,13 +145,15 @@ class _SmoothAnimationWidgetState extends State<SmoothAnimationWidget>
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_animationController =
|
||||
AnimationController(duration: const Duration(seconds: 1), vsync: this);
|
||||
_animationController = AnimationController(
|
||||
duration: const Duration(seconds: 1),
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
_borderAnimation = BorderRadiusTween(
|
||||
begin: BorderRadius.circular(100.0),
|
||||
end: BorderRadius.circular(0.0))
|
||||
.animate(_animationController);
|
||||
begin: BorderRadius.circular(100.0),
|
||||
end: BorderRadius.circular(0.0),
|
||||
).animate(_animationController);
|
||||
|
||||
_animationController.repeat(reverse: true);
|
||||
}
|
||||
@@ -170,16 +171,11 @@ class _SmoothAnimationWidgetState extends State<SmoothAnimationWidget>
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
colors: [
|
||||
Colors.blueAccent,
|
||||
Colors.redAccent,
|
||||
],
|
||||
colors: [Colors.blueAccent, Colors.redAccent],
|
||||
),
|
||||
borderRadius: _borderAnimation.value,
|
||||
),
|
||||
child: const FlutterLogo(
|
||||
size: 200,
|
||||
),
|
||||
child: const FlutterLogo(size: 200),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user