Change type of SizeAttribute from String to double

pull/41/head^2
li3317 4 years ago
parent c2c5b2a90f
commit 16e2473079
  1. 24
      app/assets/sample_data.json
  2. 6
      lib/widgets/text_line.dart
  3. 3
      lib/widgets/toolbar.dart

@ -473,6 +473,30 @@
},
"insert": "Huge"
},
{
"attributes": {
"size": "15.0"
},
"insert": "font size 15"
},
{
"insert": " "
},
{
"attributes": {
"size": "35"
},
"insert": "font size 35"
},
{
"insert": " "
},
{
"attributes": {
"size": "20"
},
"insert": "font size 20"
},
{
"insert": "\n"
}

@ -153,7 +153,11 @@ class TextLine extends StatelessWidget {
res = res.merge(defaultStyles.sizeHuge);
break;
default:
throw "Invalid size ${size.value}";
double fontSize = double.tryParse(size.value);
if (fontSize != null) {
res = res.merge(TextStyle(fontSize: fontSize));
} else
throw "Invalid size ${size.value}";
}
}

@ -784,6 +784,9 @@ class _HistoryButtonState extends State<HistoryButton> {
}
void _setIconColor() {
if(!mounted) return;
if (widget.undo) {
setState(() {
_iconColor = widget.controller.hasUndo

Loading…
Cancel
Save