我的会话创建代码位于
下方class MainWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return MainWidgetState();
}
}
class MainWidgetState extends State<MainWidget> {
// list of the child widget
List<ChildWidget> listChildWidget = [];
void addChildWidget() {
setState(() {
listChildWidget.add(ChildWidget());
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: new Text('Test'),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
addChildWidget();
}),
body: new Column(
children: <Widget>[
Expanded(
child: new ListView.builder(
itemCount: listChildWidget.length,
itemBuilder: (context, index) {
return new ListTile(title: listChildWidget[0]);
})),
// Get summary of all the list items
RaisedButton(
child: Text('Get Summary'),
onPressed: (){
// Get the list of all the textField values and their modified
// counter values
})
],
),
);
}
}
class ChildWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return ChildWidgetState();
}
}
class ChildWidgetState extends State<ChildWidget> {
int counterValue = 0;
TextEditingController myTextController;
@override
Widget build(BuildContext context) {
// TODO: implement build
return new Row(
children: <Widget>[
// counter name
Container(
child: TextField(
controller: myTextController,
textAlign: TextAlign.center,
),
width: 100.0,
),
// counter text
Text(counterValue.toString()),
// increases the counter value
IconButton(
icon: Icon(Icons.add_circle),
onPressed: () {
setState(() => counterValue += 1);
})
],
);
}
}
当我们收到付款网关的回复时,我收到代码的会话在下面
public ActionResult TestReq()
{
Session["mydata"] = "xyz";
}
但是我们获得了会话值 public ActionResult TestRes()
{
var result = Session["mydata"];
}