Skip to content
pubscout

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
$ flutter pub add csslib
Source repository

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

Works with

Packages commonly used together with csslib: ones it builds on, ones built on it, and its own family.