Flutter将TextStyle存储在Firestore中

I need to store a TextStyle in firestore but i don't know how, this is the TextStyle that i stored in firestore as string but i don't know how to convert it from a string to TextStyle so i can apply it to a text widget:

GoogleFonts.lato(
    textStyle: TextStyle(
        fontSize: 14.0,
        color: Color(0xFFaaaaaa),
        fontWeight: FontWeight.bold,
        height: 1.3,
    ),
);

I tried to store only the google font name like lato in the example above but i had the same problem, i don't know how to inject it into the TextStyle object.

The problem is the google font library has about 900 fonts, if they were just a few i could make a map that convert id to TextStyle then store those ids in firestore, but i the number of fonts are big.

有什么方法或解决办法可以使这项工作成功?

评论