如何在另一个 class 中使用一个 getter?
How to use a getter in another class?
在我的classTabelle
我交了一个称号。现在我想在class_TabelleState
中输出一个Text(this.title)
。但是我收到错误 'the getter title isnt defined for the type _TabelleState'
如何在 _TabelleState class 中使用 this.title?
class Tabelle extends StatefulWidget {
Tabelle({Key key, this.title}) : super(key: key);
final String title;
@override
_TabelleState createState() => _TabelleState();
}
class _TabelleState extends State<Tabelle> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(this.title),
对于有状态小部件,您可以从其状态访问关联的小部件:
class Tabelle extends StatefulWidget {
Tabelle({Key key, this.title}) : super(key: key);
final String title;
@override
_TabelleState createState() => _TabelleState();
}
class _TabelleState extends State<Tabelle> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),// Here is the magic
在我的classTabelle
我交了一个称号。现在我想在class_TabelleState
中输出一个Text(this.title)
。但是我收到错误 'the getter title isnt defined for the type _TabelleState'
如何在 _TabelleState class 中使用 this.title?
class Tabelle extends StatefulWidget {
Tabelle({Key key, this.title}) : super(key: key);
final String title;
@override
_TabelleState createState() => _TabelleState();
}
class _TabelleState extends State<Tabelle> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(this.title),
对于有状态小部件,您可以从其状态访问关联的小部件:
class Tabelle extends StatefulWidget {
Tabelle({Key key, this.title}) : super(key: key);
final String title;
@override
_TabelleState createState() => _TabelleState();
}
class _TabelleState extends State<Tabelle> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),// Here is the magic