How to create FilteringTextInputFormatter regx for following digits?

Viewed 20

I'm trying to create FilteringTextInputFormatter regx for follwing digits

12.1
12.12
123.12

here minium two digit should be entered befor allowing decimal
and maximum two decimal allowed.

here are the invalid regx digits
.1
.12
1.1
1.12

currently i'm using the following regx but it's not working as expected

RegExp(r'^\d{0,3}\.?\d{0,2}')
TextField(
  keyboardType: TextInputType.number,
  inputFormatters: [
    FilteringTextInputFormatter.allow(
      RegExp(r'^\d{0,3}\.?\d{0,2}'),
    )
   ],
  ),
1 Answers
textfiled(
                                    context: context,
                                    hint: "Enter amount",
                                    hintSize: 16,
                                    // inputFormatters: [
                                    //   FilteringTextInputFormatter(RegExp("[0-9]"), allow: true),
                                    //   FilteringTextInputFormatter(RegExp(r'^0+'), allow: false),
                                    //   LengthLimitingTextInputFormatter(7),
                                    // ],
                                    inputFormatters: [
                                      FilteringTextInputFormatter.allow(
                                          RegExp(r'^\d{1,9}\.?\d{0,2}')),
                                    ],
                                    keyboardType:
                                        const TextInputType.numberWithOptions(
                                            signed: true, decimal: true),
                                    validator: Validation.numberOnly,
                                    textEditingController:
                                        controller.amountController),
                              ),
                            ],
                          ),
Related