【发布时间】:2020-05-09 21:55:58
【问题描述】:
我想在覆盖之前使用用 if 语句解析的数据, 怎么做? 我尝试了很多方法,但没有奏效。 请帮帮我。
import 'package:flutter/material.dart';
class MyButton extends StatefulWidget {
Function buttonFunction;
String buttonName;
MyButton(this.buttonFunction,this.buttonName);
@override
_MyButtonState createState() => _MyButtonState();
}
class _MyButtonState extends State<MyButton> {
if (widget.buttonName == "ok"){
int i =1;
}
else int i =2;
@override
Widget build(BuildContext context) {
return Container(
child: RaisedButton(
onPressed: () {
widget.buttonFunction();
},
child: Text("${widget.buttonName}",
),
),
);
}
}```
【问题讨论】:
-
这是不可能的。也许解释一下您要完成的工作,我们可以更好地为您指明正确的方向。
标签: parsing flutter dart widget stateful