【发布时间】:2022-06-10 19:50:44
【问题描述】:
我制作一个页面,该页面具有 Pageview 以显示许多容器。现在我的问题是我需要将数据从 Container-1 传递到 Container-2 作为文本或数字.. 等。同时,用户从第一个 Pageview 移动到第二个 Pageview。
这是我的页面代码:
import 'package:flutter/material.dart';
void main() => runApp(TestClass());
class TestClass extends StatefulWidget {
@override
_TestClassState createState() => _TestClassState();
}
class _TestClassState extends State<TestClass> {
final pagecontroller = PageController();
@override
Widget build(BuildContext context) {
return MaterialApp(home:Scaffold(
appBar: AppBar(
title: Text("PageView Demo"),
),
body: PageView(
controller: pagecontroller,
scrollDirection: Axis.horizontal,
children: [
Center(
child: Column(
children: [
Container(
child: Text(
"First Container-1",
style: TextStyle(fontSize: 28),
),
),
RaisedButton(
child: Text(
'Navigate to Container-2 >>',
style: TextStyle(fontSize: 24.0),
),
onPressed: () {
},
),
],
),
),
Center(
child: Container(
child: Text(
"Second Container-2 ",
style: TextStyle(fontSize: 28),
),
),
),
],
),
),
);
}
}
我如何在它之间传递数据?有什么想法吗?
【问题讨论】:
标签: flutter