1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-12 15:58:32 +00:00

[animations] new animation sample: Hero Animation Demo (#364)

This commit is contained in:
Jaideep Prasad
2020-03-18 03:48:30 +05:30
committed by GitHub
parent a165fb98ad
commit b1a4a24f64
3 changed files with 67 additions and 1 deletions

View File

@@ -0,0 +1,60 @@
// Copyright 2019 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
class HeroAnimationDemo extends StatelessWidget {
static const String routeName = '/misc/hero_animation';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: GestureDetector(
child: Hero(
tag: 'hero-page-child',
child: _createHeroContainer(
size: 50.0,
color: Colors.grey[300],
),
),
onTap: () => Navigator.of(context)
.push<void>(MaterialPageRoute(builder: (context) => HeroPage())),
),
);
}
}
class HeroPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.lightBlue,
appBar: AppBar(),
body: Center(
child: Hero(
tag: 'hero-page-child',
child: _createHeroContainer(
size: 100.0,
color: Colors.white,
),
),
),
);
}
}
StatelessWidget _createHeroContainer({double size, Color color}) {
return Container(
height: size,
width: size,
padding: EdgeInsets.all(10.0),
margin: size < 100.0 ? EdgeInsets.all(10.0) : EdgeInsets.all(0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: color,
),
child: FlutterLogo(),
);
}