forked from qwertypool/flutter-code-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextstyles.dart
51 lines (43 loc) · 1.65 KB
/
textstyles.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Underlining Text-
//When underlining everything you can set a TextStyle on the Text widget.
Text(
'Hello world',
style: TextStyle(
decoration: TextDecoration.underline,
),
)
//If you only want to underline part of the text then you need to use Text.rich() (or a RichText widget) and break the string into TextSpans that you can add a style to.
Text.rich(
TextSpan(
text: 'Hello ',
style: TextStyle(fontSize: 50),
children: <TextSpan>[
TextSpan(
text: 'world',
style: TextStyle(
decoration: TextDecoration.underline,
)),
// can add more TextSpans here...
],
),
)
// other underlining themes ---
decorationStyle: TextDecorationStyle.dashed/ TextDecorationStyle.dotted / TextDecorationStyle.double / TextDecorationStyle.wavy
//To add space between underline FOR APPS WITH LIGHT & DARK THEME BOTH (create a dummy shadow and make the original text transparent)
final Brightness brightnessValue = MediaQuery.of(context).platformBrightness; //to check
bool isDark = brightnessValue == Brightness.dark;
Text(' Select the theme of app ',style: TextStyle(
shadows: [ isDark?
Shadow(
color: Colors.white,
offset: Offset(0, -5)):
Shadow(
color: Colors.black,
offset: Offset(0, -5))
],
color: Colors.transparent,
decoration:TextDecoration.underline,
decorationColor: isDark?Colors.white:Colors.black,
fontSize: 16,letterSpacing: 2,
fontWeight: FontWeight.bold),
),