【发布时间】:2022-01-04 09:45:25
【问题描述】:
我想调用这个方法但不能。我的目的是 从文本变量中获取字符串 使用字符串中的单词制作列表 显示列表。 我希望通过这个来做到这一点。有没有其他方法或者我可以这样做吗?
class SecondRoute extends StatefulWidget {
String text;
//const SecondRoute({Key? key}) : super(key: key);
SecondRoute({Key? key, required this.text}) : super(key: key);
@override
_SecondRouteState createState() => _SecondRouteState();
}
class _SecondRouteState extends State<SecondRoute> {
String newT ="";
List breakText(){
newT = widget.text;
var x = newT.split(" ");
print(x);
bool res = x.remove("");
while(res == true){
res = x.remove("");
}
print(x);
return x;
}
List wordlist = breakText();// can not call this method
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Second Route"),
),
body: Center(
child: Text(
"hhhh",
// text,
style: TextStyle(fontSize: 24),
),
),
);
}
}
【问题讨论】:
标签: flutter dart inheritance parent-child parent