Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed `View.of(context)` calls throwing when used with the `screenshot` package [#2662](https://github.com/singerdmx/flutter-quill/pull/2662).
- Fixed support for html named colors [#2675](https://github.com/singerdmx/flutter-quill/pull/2675)

### Added

Expand Down
10 changes: 8 additions & 2 deletions lib/src/common/utils/color.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'web_colors.dart';

import '../../editor/widgets/default_styles.dart';

Expand Down Expand Up @@ -115,7 +116,12 @@ Color stringToColor(String? s,
return Colors.brown;
}

if (s!.startsWith('rgba')) {
// is it an html named color?
if (WebColors.namedColors.containsKey(s!.toLowerCase())) {
return WebColors.namedColors[s.toLowerCase()]!;
}

if (s.startsWith('rgba')) {
s = s.substring(5); // trim left 'rgba('
s = s.substring(0, s.length - 1); // trim right ')'
final arr = s.split(',').map((e) => e.trim()).toList();
Expand All @@ -129,7 +135,7 @@ Color stringToColor(String? s,
}

if (!s.startsWith('#')) {
throw UnsupportedError('Color code not supported');
throw UnsupportedError('Color code not supported: $s');
}

var hex = s.replaceFirst('#', '');
Expand Down
Loading