In this recipe, you will create a hero animation by transforming an icon, and changing its position and size:
- Create a new file in the lib folder in your project, called listscreen.dart.
- At the top of the new file, import material.dart:
import 'package:flutter/material.dart';
- Create a stateless widget using the stless shortcut, calling the widget ListScreen:
class ListScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
}}
- At the top of the ListScreen widget, add a new List of strings, called drinks:
final List<String> drinks= ['Coffee', 'Tea', 'Cappuccino', 'Espresso'];
- In the build method, return a Scaffold. In its appBar parameter, add an AppBar with a title of 'Hero Animation':
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Hero Animation'),
),
body: Container()
);}
- In the body of the Scaffold...