Home > Blockchain >  Why is a dash diplayed as a dash on Android, but displayed as an underscore on iOS in my Flutter mob
Why is a dash diplayed as a dash on Android, but displayed as an underscore on iOS in my Flutter mob

Time:02-03

My flutter app displays a - (dash) between two times.

5:30pm - 11:00pm

On Android this displays correctly, but on iOS the dash displays as an underscore.

5:30pm _ 11:00pm

Can anyone tell me why this is and how to correct it?

            children: <Widget>[
              Row(
                children: <Widget>[
                  Expanded(
                    flex: 51,
                    child: Text(
                      data[i].jobName!,
                      style: TextStyle(color: kBodyText, fontSize: 16),
                    ),
                  ),
                  Expanded(
                    flex: 23,
                    child: Text(
                      formatJsonTime24To12(data[i].startTime!)!
                          .toLowerCase(),
                      style: TextStyle(color: kBodyText, fontSize: 16),
                      textAlign: TextAlign.right,
                    ),
                  ),
                  Expanded(
                    flex: 3,
                    child: Text(
                      ' -',
                      style: TextStyle(color: kBodyText, fontSize: 16),
                      textAlign: TextAlign.center,
                    ),
                  ),
                  Expanded(
                    flex: 23,
                    child: Text(
                      formatJsonTime24To12(data[i].finishTime!)!
                          .toLowerCase(),
                      style: TextStyle(color: kBodyText, fontSize: 16),
                      textAlign: TextAlign.right,
                    ),
                  ),
                ],
              ),

CodePudding user response:

In your TextField, just set the following code:

keyboardType: TextInputType.numberWithOptions(decimal: true),
inputFormatters: [WhitelistingTextInputFormatter(new RegExp('[ -]'))],

CodePudding user response:

It is very likely that in both cases the dash is actually display, but vertical alignment causes it to look like an underscore.

Since you are using a Row, you should try adding crossAxisAlignment: CrossAxisAlignment.baseline to all of its children.

This will tell Row to vertically align its children at their text baselines.

  •  Tags:  
  • Related