Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
gpt_markdown
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
saminsohag
2022-12-18 14:32:58 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
00d4235a678c0c73d508c464be191f062ba50e91
00d4235a
1 parent
cc27ef6b
improved documentation and optimised code
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
45 deletions
tex_text/CHANGELOG.md
tex_text/example/lib/main.dart
tex_text/lib/tex_text.dart
tex_text/pubspec.yaml
tex_text/CHANGELOG.md
View file @
00d4235
## 0.0.5
*
Code optimized and documentation improved.
## 0.0.4
*
New line support added.
...
...
tex_text/example/lib/main.dart
View file @
00d4235
...
...
@@ -30,6 +30,7 @@ class _MyAppState extends State<MyApp> {
builder:
(
context
,
child
)
{
return
TexText
(
_text
.
text
,
alignment:
TexAlignment
.
start
,
style:
Theme
.
of
(
context
)
.
textTheme
.
titleLarge
...
...
tex_text/lib/tex_text.dart
View file @
00d4235
...
...
@@ -2,40 +2,66 @@ library tex_text;
import
'package:flutter/material.dart'
;
import
'package:flutter_math_fork/flutter_math.dart'
;
export
'package:flutter_math_fork/flutter_math.dart'
;
export
'package:flutter_math_fork/flutter_math.dart'
show
MathStyle
;
enum
TexAlignment
{
/// [TexAlignment.start] aligns the words at the start of the text
start
,
/// It aligns the words at the end of the text
end
,
/// It aligns the words at the center of the text
center
,
}
/// A LaTex text view.
///
/// Example:
/// ```dart
/// TexText(r"The equation is <m>x^2+y^2=z^2<m>") //Output: The equation is <LaTex formatted equation>
///
/// // <m><m> shows <m> result
/// TexText(r"The equation is <m><m>") //Output: The equation is <m>
/// ```
class
TexText
extends
StatelessWidget
{
const
TexText
(
this
.
text
,
{
super
.
key
,
this
.
style
,
this
.
mathStyle
=
MathStyle
.
display
,
this
.
alignment
=
Wrap
Alignment
.
start
});
this
.
alignment
=
Tex
Alignment
.
start
});
final
String
text
;
final
TextStyle
?
style
;
final
MathStyle
mathStyle
;
final
Wrap
Alignment
alignment
;
final
Tex
Alignment
alignment
;
@override
Widget
build
(
BuildContext
context
)
{
return
Column
(
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
values
[
alignment
.
index
%
3
],
crossAxisAlignment:
CrossAxisAlignment
.
values
[
alignment
.
index
],
children:
text
.
split
(
'
\n
'
).
map
<
Widget
>(
(
e
)
{
return
Wrap
(
alignment:
alignment
,
alignment:
WrapAlignment
.
values
[
alignment
.
index
]
,
crossAxisAlignment:
WrapCrossAlignment
.
center
,
spacing:
4
,
children:
e
.
split
(
"<m>"
)
.
asMap
()
.
map
<
int
,
List
<
Widget
>>(
.
map
<
int
,
Iterable
<
Widget
>>(
(
index
,
e
)
{
if
(
index
.
isOdd
)
{
return
MapEntry
(
index
,
[
if
(
e
.
isEmpty
)
Text
(
"<m>"
,
textAlign:
TextAlign
.
values
[
alignment
.
index
],
style:
style
,
)
else
Math
.
tex
(
e
,
textStyle:
style
,
...
...
@@ -46,17 +72,19 @@ class TexText extends StatelessWidget {
}
return
MapEntry
(
index
,
e
.
split
(
" "
).
map
<
Widget
>((
e
)
{
e
.
split
(
" "
).
map
<
Widget
>(
(
e
)
{
return
Text
(
e
,
textAlign:
TextAlign
.
values
[
alignment
.
index
],
style:
style
,
);
}).
toList
(),
},
),
);
},
)
.
values
.
toList
()
.
expand
<
Widget
>((
element
)
=>
element
)
.
toList
(),
);
...
...
tex_text/pubspec.yaml
View file @
00d4235
name
:
tex_text
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.
version
:
0.0.
4
version
:
0.0.
5
homepage
:
https://github.com/saminsohag/flutter_packages/tree/main/tex_text
environment
:
...
...
@@ -17,39 +17,4 @@ dev_dependencies:
sdk
:
flutter
flutter_lints
:
^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter
:
\ No newline at end of file
# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
...
...
Please
register
or
login
to post a comment