我在将数据发送到第二页时遇到问题,这是我的一段代码
Navigator.push(
context,MaterialPageRoute(
builder: (BuildContext context) =>ActivityByDate(
index: date,
user: _selectedUser)));
我想将用户发送到第二页(发送到第二页的日期)
import 'package:flutter_web/material.dart';
import 'package:retgoo_internal/api/user_controller.dart';
class ActivityByDate extends StatefulWidget {
final DateTime index;
final user;
final List list;
ActivityByDate({this.index, this.user, this.list});
@override
_ActivityByDateState createState() => _ActivityByDateState();
}
class _ActivityByDateState extends State<ActivityByDate> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:
AppBar(title: Text("Activity berdasarkan tanggal"),
body: _showActivities(),
);
}
_showActivities() {
return FutureBuilder(
future: UserController.getActivityByDate(
{"date": widget.index.toIso8601String(), "id" : widget.user}),
builder: (context, snapshot) {
if (snapshot.hasData) {
if (snapshot.data != null){
print(snapshot.data);
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, position) {
var item = snapshot.data.elementAt(position);
return ListTile(
title: Text("${item["activity"]["project"]}"),
subtitle: Text(item["created_at"]),
);
});
}
}
return Text("no data displayed");
},
);
}
}
如何将用户发送到第二页,为什么只发送日期