0

My requirement is to replicate the label text as shown in the below image in my Textform label and hint shown in another image. I have referred this answer but it has limited unicodes, have also used Easy Rich Text library but it is providing me with the widget and not just a string to use in label text and hint text.

How can I achieve this? thanks. Attached code at the bottom.

image1

enter image description here

@override
  Widget build(BuildContext context) {
    return TextFormField(
      controller: controller,
      keyboardType: TextInputType.numberWithOptions(signed: true,decimal: true),
      decoration: setInputDecoration(text),
      cursorHeight: 20,
      inputFormatters: <TextInputFormatter>[
        FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
      ],
      validator: (value){
        if(value.isEmpty){
          return emptyString;
        }else if(CalculatorManager().isNotValidDouble(value)){
          return invalidInput;
        }
        return null;
      },
    );
  }

  setInputDecoration(String text) {
    return InputDecoration(
      contentPadding: EdgeInsets.fromLTRB(5.0, 3.0, 1.0, 3.0),
      filled: true,
      fillColor: Colors.white,
      focusedBorder: OutlineInputBorder(
        borderSide: BorderSide(color: Colors.lightBlueAccent, width: 2.0),
      ),
      enabledBorder: OutlineInputBorder(
        borderSide: BorderSide(color: Colors.lightBlueAccent, width: 1.0),
      ),
      hintText: text,
      labelText: text,
      hintStyle: TextStyle(
        color: Colors.grey,
      ),
      border: OutlineInputBorder(
        borderRadius: BorderRadius.all(
          Radius.circular(10.0),
        ),
        borderSide: BorderSide.none,
      ),
    );
  }
Swapnil Kadam
  • 4,075
  • 5
  • 29
  • 35

2 Answers2

0

There are two packages you may refer :

https://pub.dev/packages/characters

https://pub.dev/packages/unicode

bluenile
  • 5,673
  • 3
  • 16
  • 29
  • Please do not post "link only" answers. They go bad once the link changes. We aim to be the end of a web search, not another stepping stone that is loose and slippery. – sn- Nov 01 '20 at 10:14
0

As I can see you have used a few in the subscript letters. I would suggest creating a map of those and use it in your code. As we can't have something for ₘᵢₙ we can use Unicodes in combinations.

  Map<String, String> ksub_map = {
    'min': '\u2098\u1D62\u2099',
    't': '\u209C',
    'e': '\u2091',
  };

You can retrieve it like this in your code.

  print(ksub_map['min']);  // ₘᵢₙ
  print(ksub_map['t']);  // ₜ
  print(ksub_map['e']);  // ₑ
sn-
  • 466
  • 1
  • 5
  • 15