csslib
1.0.2, released 2 years ago by tools.dart.dev
A Dart library that parses CSS strings or byte lists into an AST.
WASM-readyQuiet but busy
What it does
It parses CSS source into a structured stylesheet object that can be inspected or debug‑printed. The API is pure Dart and works on all supported platforms.
AI-written summary of version 1.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to analyze or transform CSS in a Dart/Flutter app
- You want a lightweight, pure‑Dart way to read CSS files without native dependencies
Skip it when
- You need a full CSS rendering engine or layout engine
- You require advanced CSS features that are not yet supported
Strengths
- Pure Dart, no platform‑specific code
- Works on all Flutter platforms
- Supports many CSS units and functions
Weaknesses
- Only parses, does not render or apply styles
- May lag behind the latest CSS specifications
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:csslib/parser.dart';
void main() {
var stylesheet = parse('.foo { color: red; }');
print(stylesheet.toDebugString());
}Alternatives
Packages that do the same job and could replace csslib.
- petitparser
A generic parser combinator library that can be used to build a custom CSS parser if you need more control
93Compare
Works with
Packages commonly used together with csslib: ones it builds on, ones built on it, and its own family.
- source_spancsslib depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- analyzerSame familyPerforms static analysis of Dart code for tool integration and embedding.
- yamlSame familyA Dart library for parsing YAML documents into Dart data structures.
- dart_styleSame familyProvides an API and CLI to format Dart source code automatically.
- test_apiSame familyThe user facing API for structuring Dart tests and checking expectations.
- source_mapsSame familyA Dart library to parse, build, and manipulate source map v3 files.
- string_scannerSame familyA class for parsing strings using a sequence of patterns.
- boolean_selectorSame familyParses and evaluates simplified Dart-like boolean expression strings.