How to change flutter app keyboard color?

…衆ロ難τιáo~ 提交于 2021-02-18 13:56:27

问题


In my flutter , I create a TextFormField, but it's keyboard color is black in iOS, I want to know how to change it to white.

flutter language version: >=2.2.2 <3.0.0

this is my code about the TextFormField:

TextFormField(
     style: TextStyle(
               fontSize: 14,
               color: Colors.black),
               autofocus: false,
               initialValue: 'initial value', 
               maxLines: 1,
               // onSaved: (String value) => _person = value,
               // obscureText: _isObscure,
               validator: (String value) {
                          if (value.isEmpty) {
                            return 'nononono';
                          }
                          return null;
                        },
               decoration: InputDecoration(
                          hintText: 'please make sure',
                          contentPadding: EdgeInsets.fromLTRB(15, 5, 15, 5),
               hintStyle: TextStyle(
                             color: Colors.grey,
                             fontSize: 12,
                             ),
               hasFloatingPlaceholder: false,
               // contentPadding: contentPadding,
               border: InputBorder.none,
               ),
),

when I click this TextFormField

what I get: black keyboard

what I want: white keyboard


回答1:


White keyboard use Brightness.light

Black keyboard use Brightness.dark

    body: Center(
            child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
                TextField(
                    keyboardType: TextInputType.text,
                    keyboardAppearance: Brightness.light, // no matter what you set, it simply shows white keyboard
                )
            ],
            ),
        )


来源:https://stackoverflow.com/questions/57619369/how-to-change-flutter-app-keyboard-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!