Showing
5 changed files
with
59 additions
and
12 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, | ||
28 | + colorSchemeSeed: Colors.blue, | ||
29 | + ), | ||
30 | + darkTheme: ThemeData( | ||
31 | + useMaterial3: true, | ||
32 | + brightness: Brightness.dark, | ||
19 | colorSchemeSeed: Colors.blue, | 33 | colorSchemeSeed: Colors.blue, |
20 | ), | 34 | ), |
21 | - home: const MyHomePage(title: 'Flutter Demo Home Page'), | 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,7 +77,8 @@ class MdWidget extends StatelessWidget { | @@ -72,7 +77,8 @@ class MdWidget extends StatelessWidget { | ||
72 | children: [ | 77 | children: [ |
73 | Row( | 78 | Row( |
74 | children: [ | 79 | children: [ |
75 | - TexText( | 80 | + Expanded( |
81 | + child: TexText( | ||
76 | "${match?[2]}", | 82 | "${match?[2]}", |
77 | style: [ | 83 | style: [ |
78 | Theme.of(context) | 84 | Theme.of(context) |
@@ -101,6 +107,7 @@ class MdWidget extends StatelessWidget { | @@ -101,6 +107,7 @@ class MdWidget extends StatelessWidget { | ||
101 | ?.copyWith(color: style?.color), | 107 | ?.copyWith(color: style?.color), |
102 | ][match![1]!.length - 1], | 108 | ][match![1]!.length - 1], |
103 | ), | 109 | ), |
110 | + ), | ||
104 | ], | 111 | ], |
105 | ), | 112 | ), |
106 | if (match[1]!.length == 1) const Divider(height: 6), | 113 | if (match[1]!.length == 1) const Divider(height: 6), |
@@ -127,11 +134,13 @@ class MdWidget extends StatelessWidget { | @@ -127,11 +134,13 @@ class MdWidget extends StatelessWidget { | ||
127 | fillColor: ButtonStyleButton.allOrNull(style?.color), | 134 | fillColor: ButtonStyleButton.allOrNull(style?.color), |
128 | ), | 135 | ), |
129 | ), | 136 | ), |
130 | - MdWidget( | 137 | + Expanded( |
138 | + child: MdWidget( | ||
131 | "${match?[2]}", | 139 | "${match?[2]}", |
132 | onLinkTab: onLinkTab, | 140 | onLinkTab: onLinkTab, |
133 | style: style, | 141 | style: style, |
134 | ), | 142 | ), |
143 | + ), | ||
135 | ], | 144 | ], |
136 | ); | 145 | ); |
137 | } | 146 | } |
@@ -150,11 +159,13 @@ class MdWidget extends StatelessWidget { | @@ -150,11 +159,13 @@ class MdWidget extends StatelessWidget { | ||
150 | fillColor: ButtonStyleButton.allOrNull(style?.color), | 159 | fillColor: ButtonStyleButton.allOrNull(style?.color), |
151 | ), | 160 | ), |
152 | ), | 161 | ), |
153 | - MdWidget( | 162 | + Expanded( |
163 | + child: MdWidget( | ||
154 | "${match?[2]}", | 164 | "${match?[2]}", |
155 | onLinkTab: onLinkTab, | 165 | onLinkTab: onLinkTab, |
156 | style: style, | 166 | style: style, |
157 | ), | 167 | ), |
168 | + ), | ||
158 | ], | 169 | ], |
159 | ); | 170 | ); |
160 | } | 171 | } |
@@ -172,11 +183,13 @@ class MdWidget extends StatelessWidget { | @@ -172,11 +183,13 @@ class MdWidget extends StatelessWidget { | ||
172 | size: 8, | 183 | size: 8, |
173 | ), | 184 | ), |
174 | ), | 185 | ), |
175 | - MdWidget( | 186 | + Expanded( |
187 | + child: MdWidget( | ||
176 | "${match?[2]}", | 188 | "${match?[2]}", |
177 | onLinkTab: onLinkTab, | 189 | onLinkTab: onLinkTab, |
178 | style: style, | 190 | style: style, |
179 | ), | 191 | ), |
192 | + ), | ||
180 | ], | 193 | ], |
181 | ); | 194 | ); |
182 | } | 195 | } |
@@ -194,11 +207,13 @@ class MdWidget extends StatelessWidget { | @@ -194,11 +207,13 @@ class MdWidget extends StatelessWidget { | ||
194 | .copyWith(fontWeight: FontWeight.bold), | 207 | .copyWith(fontWeight: FontWeight.bold), |
195 | ), | 208 | ), |
196 | ), | 209 | ), |
197 | - MdWidget( | 210 | + Expanded( |
211 | + child: MdWidget( | ||
198 | "${match?[2]}", | 212 | "${match?[2]}", |
199 | onLinkTab: onLinkTab, | 213 | onLinkTab: onLinkTab, |
200 | style: style, | 214 | style: style, |
201 | ), | 215 | ), |
216 | + ), | ||
202 | ], | 217 | ], |
203 | ); | 218 | ); |
204 | } | 219 | } |
@@ -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