in the first page/screen
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("ListTile Example"),
),
body: new ListView(
children: new List.generate(20, (int index) {
return new ListTile(
onTap: () {
Navigator.of(context).push(
PageRouteBuilder(
opaque: false,
pageBuilder: (BuildContext context, _, __) => NextPage(
number: index,
),
),
);
},
title: new Text(
"Index No #$index",
style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 25.0),
),
subtitle: new Text("My subtitle is"),
);
}),
),
);
}
in the next or second page
import 'package:flutter/material.dart';
class NextPage extends StatefulWidget {
final int number;
NextPage({
Key key,
@required this.number,
}) : super(key: key);
@override
_NextPageState createState() => _NextPageState();
}
class _NextPageState extends State<NextPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(widget.number.toString()),
),
);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…