|
|
|
|
@ -1,3 +1,17 @@
|
|
|
|
|
// Copyright 2019-present the Flutter authors. All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
@ -18,24 +32,20 @@ class _PerformancePageState extends State<PerformancePage> {
|
|
|
|
|
SmoothAnimationWidget(),
|
|
|
|
|
Container(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.only(left: 0.0, top: 150.0, right: 0.0, bottom: 0.0),
|
|
|
|
|
padding: EdgeInsets.only(top: 150.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
FutureBuilder<void>(
|
|
|
|
|
future: computeFuture,
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
|
|
|
|
return RaisedButton(
|
|
|
|
|
child: const Text('Compute on Main'),
|
|
|
|
|
elevation: 8.0,
|
|
|
|
|
onPressed: (snapshot.connectionState ==
|
|
|
|
|
ConnectionState.done)
|
|
|
|
|
? () {
|
|
|
|
|
setState(
|
|
|
|
|
() {
|
|
|
|
|
computeFuture = computeOnMainIsolate()
|
|
|
|
|
..then(
|
|
|
|
|
(_) {
|
|
|
|
|
ConnectionState.done) ? () {
|
|
|
|
|
setState( () {
|
|
|
|
|
computeFuture = computeOnMainIsolate()
|
|
|
|
|
..then( (_) {
|
|
|
|
|
final snackBar1 = SnackBar(
|
|
|
|
|
content: Text('Main Isolate Done!'),
|
|
|
|
|
);
|
|
|
|
|
@ -52,18 +62,15 @@ class _PerformancePageState extends State<PerformancePage> {
|
|
|
|
|
),
|
|
|
|
|
FutureBuilder<void>(
|
|
|
|
|
future: computeFuture,
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
|
|
|
|
return RaisedButton(
|
|
|
|
|
child: const Text('Compute on Secondary'),
|
|
|
|
|
elevation: 8.0,
|
|
|
|
|
onPressed: (snapshot.connectionState ==
|
|
|
|
|
ConnectionState.done)
|
|
|
|
|
? () {
|
|
|
|
|
setState(
|
|
|
|
|
() {
|
|
|
|
|
ConnectionState.done) ? () {
|
|
|
|
|
setState( () {
|
|
|
|
|
computeFuture = computeOnSecondaryIsolate()
|
|
|
|
|
..then(
|
|
|
|
|
(_) {
|
|
|
|
|
..then( (_) {
|
|
|
|
|
final snackBar1 = SnackBar(
|
|
|
|
|
content:
|
|
|
|
|
Text('Secondary Isolate Done!'),
|
|
|
|
|
@ -123,16 +130,13 @@ class SmoothAnimationWidgetState extends State<SmoothAnimationWidget>
|
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
|
AnimationController _controller;
|
|
|
|
|
var borderRadius;
|
|
|
|
|
var transitionTween;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
_controller =
|
|
|
|
|
AnimationController(duration: const Duration(seconds: 1), vsync: this)
|
|
|
|
|
..addStatusListener(
|
|
|
|
|
(status) {
|
|
|
|
|
_controller = AnimationController(duration: const Duration(seconds: 1), vsync: this)
|
|
|
|
|
..addStatusListener( (status) {
|
|
|
|
|
if (status == AnimationStatus.completed) {
|
|
|
|
|
_controller.reverse();
|
|
|
|
|
} else if (status == AnimationStatus.dismissed) {
|
|
|
|
|
@ -154,12 +158,6 @@ class SmoothAnimationWidgetState extends State<SmoothAnimationWidget>
|
|
|
|
|
_controller.forward();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_controller.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return AnimatedBuilder(
|
|
|
|
|
@ -176,7 +174,7 @@ class SmoothAnimationWidgetState extends State<SmoothAnimationWidget>
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
begin: Alignment.topLeft,
|
|
|
|
|
colors: [
|
|
|
|
|
colors: <Color>[
|
|
|
|
|
Colors.blueAccent,
|
|
|
|
|
Colors.redAccent
|
|
|
|
|
], // whitish to gray
|
|
|
|
|
@ -188,4 +186,10 @@ class SmoothAnimationWidgetState extends State<SmoothAnimationWidget>
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_controller.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|