Простой пример
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: Home(),
));
class Home extends StatelessWidget {
final List<String> litems = [
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5",
"Item 6",
"Item 7"
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Hero List'),
),
body: ListView.builder(
itemCount: litems.length,
itemBuilder: (BuildContext ctxt, int index) {
return ListTile(
title: Hero(
tag: '${litems[index]}__heroTag',
child: Text(
litems[index],
style: Theme.of(context).textTheme.title,
),
),
trailing: IconButton(
icon: Icon(Icons.navigate_next),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ItemScreen(
itemName: litems[index],
)),
);
}),
);
},
),
);
}
}
class ItemScreen extends StatelessWidget {
final String itemName;
const ItemScreen({Key key, @required this.itemName}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(itemName),
),
body: Container(
child: Center(
child: Hero(
tag: '${itemName}__heroTag',
child: Text(
itemName,
style: Theme.of(context).textTheme.title,
),
),
),
),
);
}
}