Showing
3 changed files
with
57 additions
and
42 deletions
| @@ -43,51 +43,62 @@ class TexText extends StatelessWidget { | @@ -43,51 +43,62 @@ class TexText extends StatelessWidget { | ||
| 43 | children: text.split('\n').map<Widget>( | 43 | children: text.split('\n').map<Widget>( |
| 44 | (e) { | 44 | (e) { |
| 45 | return Wrap( | 45 | return Wrap( |
| 46 | - alignment: WrapAlignment.values[alignment.index], | ||
| 47 | - crossAxisAlignment: WrapCrossAlignment.center, | ||
| 48 | - spacing: 4, | ||
| 49 | - children: e | ||
| 50 | - .split(r'$') | ||
| 51 | - .asMap() | ||
| 52 | - .map<int, Iterable<Widget>>( | ||
| 53 | - (index, e) { | ||
| 54 | - if (index.isOdd) { | 46 | + alignment: WrapAlignment.values[alignment.index], |
| 47 | + crossAxisAlignment: WrapCrossAlignment.center, | ||
| 48 | + children: e | ||
| 49 | + .split(r'$') | ||
| 50 | + .asMap() | ||
| 51 | + .map<int, Iterable<Widget>>( | ||
| 52 | + (index, e) { | ||
| 53 | + if (index.isOdd) { | ||
| 54 | + return MapEntry( | ||
| 55 | + index, | ||
| 56 | + [ | ||
| 57 | + if (e.isEmpty) | ||
| 58 | + Text( | ||
| 59 | + r'$', | ||
| 60 | + textAlign: TextAlign.values[alignment.index], | ||
| 61 | + style: style, | ||
| 62 | + ) | ||
| 63 | + else | ||
| 64 | + Math.tex( | ||
| 65 | + e, | ||
| 66 | + textStyle: style, | ||
| 67 | + mathStyle: mathStyle, | ||
| 68 | + ), | ||
| 69 | + ], | ||
| 70 | + ); | ||
| 71 | + } | ||
| 55 | return MapEntry( | 72 | return MapEntry( |
| 56 | index, | 73 | index, |
| 57 | - [ | ||
| 58 | - if (e.isEmpty) | ||
| 59 | - Text( | ||
| 60 | - r'$', | ||
| 61 | - textAlign: TextAlign.values[alignment.index], | ||
| 62 | - style: style, | 74 | + e |
| 75 | + .split(" ") | ||
| 76 | + .asMap() | ||
| 77 | + .map<int, Iterable<Widget>>( | ||
| 78 | + (index, e) { | ||
| 79 | + return MapEntry(index, [ | ||
| 80 | + if (index != 0) | ||
| 81 | + Text( | ||
| 82 | + " ", | ||
| 83 | + style: style, | ||
| 84 | + ), | ||
| 85 | + Text( | ||
| 86 | + e, | ||
| 87 | + textAlign: | ||
| 88 | + TextAlign.values[alignment.index], | ||
| 89 | + style: style, | ||
| 90 | + ), | ||
| 91 | + ]); | ||
| 92 | + }, | ||
| 63 | ) | 93 | ) |
| 64 | - else | ||
| 65 | - Math.tex( | ||
| 66 | - e, | ||
| 67 | - textStyle: style, | ||
| 68 | - mathStyle: mathStyle, | ||
| 69 | - ), | ||
| 70 | - ], | 94 | + .values |
| 95 | + .expand((element) => element), | ||
| 71 | ); | 96 | ); |
| 72 | - } | ||
| 73 | - return MapEntry( | ||
| 74 | - index, | ||
| 75 | - e.split(" ").map<Widget>( | ||
| 76 | - (e) { | ||
| 77 | - return Text( | ||
| 78 | - e, | ||
| 79 | - textAlign: TextAlign.values[alignment.index], | ||
| 80 | - style: style, | ||
| 81 | - ); | ||
| 82 | - }, | ||
| 83 | - ), | ||
| 84 | - ); | ||
| 85 | - }, | ||
| 86 | - ) | ||
| 87 | - .values | ||
| 88 | - .expand<Widget>((element) => element) | ||
| 89 | - .toList(), | ||
| 90 | - ); | 97 | + }, |
| 98 | + ) | ||
| 99 | + .values | ||
| 100 | + .expand<Widget>((element) => element) | ||
| 101 | + .toList()); | ||
| 91 | }, | 102 | }, |
| 92 | ).toList(), | 103 | ).toList(), |
| 93 | ); | 104 | ); |
| 1 | name: tex_text | 1 | name: tex_text |
| 2 | description: This package for Flutter allows you to show text on a Flutter app with LaTex math formula and normal text from string. It is vary easy to use and works for all of the platforms. | 2 | description: This package for Flutter allows you to show text on a Flutter app with LaTex math formula and normal text from string. It is vary easy to use and works for all of the platforms. |
| 3 | -version: 0.0.6 | 3 | +version: 0.0.7 |
| 4 | homepage: https://github.com/saminsohag/flutter_packages/tree/main/tex_text | 4 | homepage: https://github.com/saminsohag/flutter_packages/tree/main/tex_text |
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
-
Please register or login to post a comment