//flutter
import 'package:flutter/material.dart';
void main() {
return runApp(TestPage());
}
//リスト4.50_cf
class TestPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Hero',
home: Scaffold(
appBar: AppBar(title: Text('Hero')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Hero(
tag: 'icon',
child: Image.asset(
'images/icon.png',
width: 100,
height: 100,
)
),
ElevatedButton(
onPressed: () =>
Navigator.of(context).pushNamed('/detail_page'),
child: Text('Hero'),
)
]
)
)
)
);
}
}
class DetailPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Hero',
home: Scaffold(
appBar: AppBar(title: Text('Hero')),
body: Center(
child: Hero(
tag: 'icon',
child: Image.asset(
'images/icon.png',
width: 300,
height: 300,
)
)
)
)
);
}
}