Flutter Labeltext AppLocalizations TextField

时间:2020-05-25 20:50:17

标签: flutter localization textfield

我正在尝试更改TextField中的labeltext。我在使用AppLocalization值更改标签文本时遇到问题-如何更改标签文本?

Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(AppLocalizations.of(context).translate('Hopsalpha'),),
          backgroundColor: Colors.green[800],

          //elevation: 0.0,
        ),
        body: Center(
          child: Container(

            child: Column(
              children: <Widget>[
                Container(
                  padding: EdgeInsets.all(20.0),
                  child: TextField(
                    cursorColor: Colors.green[800],
                    controller: _weight,
                    decoration: InputDecoration(
                        focusedBorder: UnderlineInputBorder(
                          borderSide: BorderSide(color: Colors.green[800], width: 2.0,),
                        ),

                        filled: true,
                        fillColor: Colors.green[10],

                        labelText: AppLocalizations.of(context).translate('weightreceipe'),
                        labelStyle: TextStyle(color: Colors.green[800])
                    ),
                    keyboardType: TextInputType.number,
                    inputFormatters: <TextInputFormatter>[
                      WhitelistingTextInputFormatter.digitsOnly
                    ],
                  ),
                ),

0 个答案:

没有答案