Showing
5 changed files
with
98 additions
and
51 deletions
@@ -7,24 +7,46 @@ void main() { | @@ -7,24 +7,46 @@ void main() { | ||
7 | runApp(const MyApp()); | 7 | runApp(const MyApp()); |
8 | } | 8 | } |
9 | 9 | ||
10 | -class MyApp extends StatelessWidget { | 10 | +class MyApp extends StatefulWidget { |
11 | const MyApp({super.key}); | 11 | const MyApp({super.key}); |
12 | 12 | ||
13 | @override | 13 | @override |
14 | + State<MyApp> createState() => _MyAppState(); | ||
15 | +} | ||
16 | + | ||
17 | +class _MyAppState extends State<MyApp> { | ||
18 | + ThemeMode _themeMode = ThemeMode.light; | ||
19 | + @override | ||
14 | Widget build(BuildContext context) { | 20 | Widget build(BuildContext context) { |
15 | return MaterialApp( | 21 | return MaterialApp( |
22 | + debugShowCheckedModeBanner: false, | ||
16 | title: 'Flutter Demo', | 23 | title: 'Flutter Demo', |
24 | + themeMode: _themeMode, | ||
17 | theme: ThemeData( | 25 | theme: ThemeData( |
18 | useMaterial3: true, | 26 | useMaterial3: true, |
27 | + brightness: Brightness.light, | ||
19 | colorSchemeSeed: Colors.blue, | 28 | colorSchemeSeed: Colors.blue, |
20 | ), | 29 | ), |
21 | - home: const MyHomePage(title: 'Flutter Demo Home Page'), | 30 | + darkTheme: ThemeData( |
31 | + useMaterial3: true, | ||
32 | + brightness: Brightness.dark, | ||
33 | + colorSchemeSeed: Colors.blue, | ||
34 | + ), | ||
35 | + home: MyHomePage( | ||
36 | + title: 'Flutter Demo Home Page', | ||
37 | + onPressed: () { | ||
38 | + setState(() { | ||
39 | + _themeMode = ThemeMode.values[(_themeMode.index + 1) % 2]; | ||
40 | + }); | ||
41 | + }, | ||
42 | + ), | ||
22 | ); | 43 | ); |
23 | } | 44 | } |
24 | } | 45 | } |
25 | 46 | ||
26 | class MyHomePage extends StatefulWidget { | 47 | class MyHomePage extends StatefulWidget { |
27 | - const MyHomePage({super.key, required this.title}); | 48 | + const MyHomePage({super.key, required this.title, required this.onPressed}); |
49 | + final VoidCallback? onPressed; | ||
28 | 50 | ||
29 | final String title; | 51 | final String title; |
30 | 52 | ||
@@ -61,6 +83,12 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -61,6 +83,12 @@ class _MyHomePageState extends State<MyHomePage> { | ||
61 | return Scaffold( | 83 | return Scaffold( |
62 | appBar: AppBar( | 84 | appBar: AppBar( |
63 | title: Text(widget.title), | 85 | title: Text(widget.title), |
86 | + actions: [ | ||
87 | + IconButton( | ||
88 | + onPressed: widget.onPressed, | ||
89 | + icon: const Icon(Icons.sunny), | ||
90 | + ), | ||
91 | + ], | ||
64 | ), | 92 | ), |
65 | body: Column( | 93 | body: Column( |
66 | children: [ | 94 | children: [ |
@@ -204,7 +204,7 @@ packages: | @@ -204,7 +204,7 @@ packages: | ||
204 | path: ".." | 204 | path: ".." |
205 | relative: true | 205 | relative: true |
206 | source: path | 206 | source: path |
207 | - version: "0.0.3" | 207 | + version: "0.0.4" |
208 | tex_text: | 208 | tex_text: |
209 | dependency: transitive | 209 | dependency: transitive |
210 | description: | 210 | description: |
1 | +import 'dart:developer'; | ||
2 | + | ||
1 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
2 | import 'package:tex_text/tex_text.dart'; | 4 | import 'package:tex_text/tex_text.dart'; |
3 | 5 | ||
@@ -47,7 +49,10 @@ class MdWidget extends StatelessWidget { | @@ -47,7 +49,10 @@ class MdWidget extends StatelessWidget { | ||
47 | } | 49 | } |
48 | return Table( | 50 | return Table( |
49 | defaultVerticalAlignment: TableCellVerticalAlignment.middle, | 51 | defaultVerticalAlignment: TableCellVerticalAlignment.middle, |
50 | - border: TableBorder.all(width: 1), | 52 | + border: TableBorder.all( |
53 | + width: 1, | ||
54 | + color: Theme.of(context).colorScheme.onSurface, | ||
55 | + ), | ||
51 | children: value | 56 | children: value |
52 | .map<TableRow>( | 57 | .map<TableRow>( |
53 | (e) => TableRow( | 58 | (e) => TableRow( |
@@ -72,34 +77,36 @@ class MdWidget extends StatelessWidget { | @@ -72,34 +77,36 @@ class MdWidget extends StatelessWidget { | ||
72 | children: [ | 77 | children: [ |
73 | Row( | 78 | Row( |
74 | children: [ | 79 | children: [ |
75 | - TexText( | ||
76 | - "${match?[2]}", | ||
77 | - style: [ | ||
78 | - Theme.of(context) | ||
79 | - .textTheme | ||
80 | - .headlineLarge | ||
81 | - ?.copyWith(color: style?.color), | ||
82 | - Theme.of(context) | ||
83 | - .textTheme | ||
84 | - .headlineMedium | ||
85 | - ?.copyWith(color: style?.color), | ||
86 | - Theme.of(context) | ||
87 | - .textTheme | ||
88 | - .headlineSmall | ||
89 | - ?.copyWith(color: style?.color), | ||
90 | - Theme.of(context) | ||
91 | - .textTheme | ||
92 | - .titleLarge | ||
93 | - ?.copyWith(color: style?.color), | ||
94 | - Theme.of(context) | ||
95 | - .textTheme | ||
96 | - .titleMedium | ||
97 | - ?.copyWith(color: style?.color), | ||
98 | - Theme.of(context) | ||
99 | - .textTheme | ||
100 | - .titleSmall | ||
101 | - ?.copyWith(color: style?.color), | ||
102 | - ][match![1]!.length - 1], | 80 | + Expanded( |
81 | + child: TexText( | ||
82 | + "${match?[2]}", | ||
83 | + style: [ | ||
84 | + Theme.of(context) | ||
85 | + .textTheme | ||
86 | + .headlineLarge | ||
87 | + ?.copyWith(color: style?.color), | ||
88 | + Theme.of(context) | ||
89 | + .textTheme | ||
90 | + .headlineMedium | ||
91 | + ?.copyWith(color: style?.color), | ||
92 | + Theme.of(context) | ||
93 | + .textTheme | ||
94 | + .headlineSmall | ||
95 | + ?.copyWith(color: style?.color), | ||
96 | + Theme.of(context) | ||
97 | + .textTheme | ||
98 | + .titleLarge | ||
99 | + ?.copyWith(color: style?.color), | ||
100 | + Theme.of(context) | ||
101 | + .textTheme | ||
102 | + .titleMedium | ||
103 | + ?.copyWith(color: style?.color), | ||
104 | + Theme.of(context) | ||
105 | + .textTheme | ||
106 | + .titleSmall | ||
107 | + ?.copyWith(color: style?.color), | ||
108 | + ][match![1]!.length - 1], | ||
109 | + ), | ||
103 | ), | 110 | ), |
104 | ], | 111 | ], |
105 | ), | 112 | ), |
@@ -127,10 +134,12 @@ class MdWidget extends StatelessWidget { | @@ -127,10 +134,12 @@ class MdWidget extends StatelessWidget { | ||
127 | fillColor: ButtonStyleButton.allOrNull(style?.color), | 134 | fillColor: ButtonStyleButton.allOrNull(style?.color), |
128 | ), | 135 | ), |
129 | ), | 136 | ), |
130 | - MdWidget( | ||
131 | - "${match?[2]}", | ||
132 | - onLinkTab: onLinkTab, | ||
133 | - style: style, | 137 | + Expanded( |
138 | + child: MdWidget( | ||
139 | + "${match?[2]}", | ||
140 | + onLinkTab: onLinkTab, | ||
141 | + style: style, | ||
142 | + ), | ||
134 | ), | 143 | ), |
135 | ], | 144 | ], |
136 | ); | 145 | ); |
@@ -150,10 +159,12 @@ class MdWidget extends StatelessWidget { | @@ -150,10 +159,12 @@ class MdWidget extends StatelessWidget { | ||
150 | fillColor: ButtonStyleButton.allOrNull(style?.color), | 159 | fillColor: ButtonStyleButton.allOrNull(style?.color), |
151 | ), | 160 | ), |
152 | ), | 161 | ), |
153 | - MdWidget( | ||
154 | - "${match?[2]}", | ||
155 | - onLinkTab: onLinkTab, | ||
156 | - style: style, | 162 | + Expanded( |
163 | + child: MdWidget( | ||
164 | + "${match?[2]}", | ||
165 | + onLinkTab: onLinkTab, | ||
166 | + style: style, | ||
167 | + ), | ||
157 | ), | 168 | ), |
158 | ], | 169 | ], |
159 | ); | 170 | ); |
@@ -172,10 +183,12 @@ class MdWidget extends StatelessWidget { | @@ -172,10 +183,12 @@ class MdWidget extends StatelessWidget { | ||
172 | size: 8, | 183 | size: 8, |
173 | ), | 184 | ), |
174 | ), | 185 | ), |
175 | - MdWidget( | ||
176 | - "${match?[2]}", | ||
177 | - onLinkTab: onLinkTab, | ||
178 | - style: style, | 186 | + Expanded( |
187 | + child: MdWidget( | ||
188 | + "${match?[2]}", | ||
189 | + onLinkTab: onLinkTab, | ||
190 | + style: style, | ||
191 | + ), | ||
179 | ), | 192 | ), |
180 | ], | 193 | ], |
181 | ); | 194 | ); |
@@ -194,10 +207,12 @@ class MdWidget extends StatelessWidget { | @@ -194,10 +207,12 @@ class MdWidget extends StatelessWidget { | ||
194 | .copyWith(fontWeight: FontWeight.bold), | 207 | .copyWith(fontWeight: FontWeight.bold), |
195 | ), | 208 | ), |
196 | ), | 209 | ), |
197 | - MdWidget( | ||
198 | - "${match?[2]}", | ||
199 | - onLinkTab: onLinkTab, | ||
200 | - style: style, | 210 | + Expanded( |
211 | + child: MdWidget( | ||
212 | + "${match?[2]}", | ||
213 | + onLinkTab: onLinkTab, | ||
214 | + style: style, | ||
215 | + ), | ||
201 | ), | 216 | ), |
202 | ], | 217 | ], |
203 | ); | 218 | ); |
@@ -228,7 +243,7 @@ class MdWidget extends StatelessWidget { | @@ -228,7 +243,7 @@ class MdWidget extends StatelessWidget { | ||
228 | if (onLinkTab == null) { | 243 | if (onLinkTab == null) { |
229 | return; | 244 | return; |
230 | } | 245 | } |
231 | - onLinkTab!("${match?[1]}", "${match?[2]}"); | 246 | + onLinkTab!("${match?[2]}", "${match?[1]}"); |
232 | }, | 247 | }, |
233 | child: MdWidget( | 248 | child: MdWidget( |
234 | "${match?[1]}", | 249 | "${match?[1]}", |
1 | name: tex_markdown | 1 | name: tex_markdown |
2 | description: This package is used to create flutter widget that can render markdown and latex formulas. It is very simple to use and uses native flutter components. | 2 | description: This package is used to create flutter widget that can render markdown and latex formulas. It is very simple to use and uses native flutter components. |
3 | -version: 0.0.3 | 3 | +version: 0.0.4 |
4 | homepage: https://github.com/saminsohag/flutter_packages/tree/main/tex_markdown | 4 | homepage: https://github.com/saminsohag/flutter_packages/tree/main/tex_markdown |
5 | 5 | ||
6 | environment: | 6 | environment: |
-
Please register or login to post a comment