Search code examples
flutterthemesios-darkmodeflutter-cupertino

Force light mode on CupertinoTextField Flutter


I'm developing a mobile app in Flutter, and until now I only designed a light mode UI and everything is working fine, but if I try to add a CupertinoTextField, since my phone is in dark mode it will appear black. Is there an easy way to force it to be light? I wasn't even able to find how to just change its color.

Here's my code:

final TextEditingController _textController = TextEditingController();    

CupertinoTextField(
     controller: _textController,
     keyboardType: TextInputType.multiline,
     minLines: 1,
     maxLines: 5,
     placeholder: 'Type a message'
    )

Solution

  • You can change the color by adding a BoxDecoration in the CupertinoTextField

    CupertinoTextField(
              controller: _textController,
              keyboardType: TextInputType.multiline,
              minLines: 1,
              maxLines: 5,
              placeholder: 'Type a message',
              decoration: BoxDecoration(
                color: Colors.white,
              ),
            )