从Flutter中的Text()小部件获取字符串内容

Fox*_*ror 5 android text dart flutter

定义后是否可以String从小Text()部件获取值?

范例程式码

Text txt = Text("example text");

getValueFromtxt() {
  var value = txt.text;                  <------
}

@override
Widget build(BuildContext context) {
  return txt;
}
Run Code Online (Sandbox Code Playgroud)

Fox*_*ror 8

我使用起来并不困难Text().data

Text txt = Text("example text");

getValueFromtxt() {
  var value = txt.data;                  <------
}

@override
Widget build(BuildContext context) {
  return txt;
}
Run Code Online (Sandbox Code Playgroud)