-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.dart
145 lines (136 loc) · 3.76 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import 'package:flutter/material.dart';
import 'package:text_style_editor/text_style_editor.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'TextStyleEditor Demo',
theme: ThemeData.light(),
// theme: ThemeData.dark(),
home: MyHomePage(title: 'TextStyleEditor Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List<String> fonts = [
'Billabong',
'AlexBrush',
'Allura',
'Arizonia',
'ChunkFive',
'GrandHotel',
'GreatVibes',
'Lobster',
'OpenSans',
'OstrichSans',
'Oswald',
'Pacifico',
'Quicksand',
'Roboto',
'SEASRN',
'Windsong',
];
List<Color> paletteColors = [
Colors.black,
Colors.white,
Color(int.parse('0xffEA2027')),
Color(int.parse('0xff006266')),
Color(int.parse('0xff1B1464')),
Color(int.parse('0xff5758BB')),
Color(int.parse('0xff6F1E51')),
Color(int.parse('0xffB53471')),
Color(int.parse('0xffEE5A24')),
Color(int.parse('0xff009432')),
Color(int.parse('0xff0652DD')),
Color(int.parse('0xff9980FA')),
Color(int.parse('0xff833471')),
Color(int.parse('0xff112CBC4')),
Color(int.parse('0xffFDA7DF')),
Color(int.parse('0xffED4C67')),
Color(int.parse('0xffF79F1F')),
Color(int.parse('0xffA3CB38')),
Color(int.parse('0xff1289A7')),
Color(int.parse('0xffD980FA'))
];
TextStyle textStyle;
TextAlign textAlign;
@override
void initState() {
textStyle = TextStyle(
fontSize: 15,
color: Colors.white,
fontFamily: 'OpenSans',
);
textAlign = TextAlign.left;
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Column(
children: <Widget>[
Expanded(
child: Align(
alignment: Alignment.center,
child: Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
style: textStyle,
textAlign: textAlign,
maxLines: 10,
),
),
),
SafeArea(
bottom: false,
child: Container(
height: 300,
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
border: Border.symmetric(
horizontal: BorderSide(
color: Theme.of(context).backgroundColor,
),
),
),
child: Align(
alignment: Alignment.topCenter,
child: TextStyleEditor(
fonts: fonts,
paletteColors: paletteColors,
textStyle: textStyle,
textAlign: textAlign,
initialTool: EditorToolbarAction.fontFamilyTool,
onTextAlignEdited: (align) {
setState(() {
textAlign = align;
});
},
onTextStyleEdited: (style) {
setState(() {
textStyle = textStyle.merge(style);
});
},
onCpasLockTaggle: (caps) {
print(caps);
},
),
),
),
),
],
),
),
);
}
}