scopify 0.2.0

  • Installing
  • Versions
  • 62


scopify implements scoped styling in a manner similar to HTML5 and Vue. It processes the given HTML nodes and CSS stylesheets in-place, adding specialized attributes that make sure the CSS can only ever modify the given HTML.


import 'package:csslib/parser.dart' as css;
import 'package:csslib/visitor.dart' show CssPrinter;
import 'package:html/parser.dart' as html;

import 'package:scopify/scopify.dart';

void main() {
  var myCss = 'p#my-id { color: purple; }';
  var myHtml = '<p id="my-id">purplified text here</p>';

  // First, we have to parse the CSS and HTMl text.
  var style = css.parse(myCss);
  var node = html.parse(myHtml);

  // Now, we can call scopify. It takes two arguments: a list of HTML nodes, and a list of CSS
  // stylesheets to process.
  scopify(html: [node], css: [style]);

  // The HTML and CSS parse trees were modified in-place. Now, the CSS will only ever modify this
  // HTML code, even when combined with other HTML code.

  // To get the resulting HTML:
  var resultHtml = node.outerHtml;

  // and CSS:
  var printer = new CssPrinter();
  var resultCss = printer.toString();



Scoped styles have been changed now will not automatically "bleed" into other scoped styles. Bleeding can still be manually enabled, but it will still not bleed into other styles managed by scopify, e.g. it is more restrictive.


Initial version.

1. Depend on it

Add this to your package's pubspec.yaml file:

  scopify: "^0.2.0"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:scopify/scopify.dart';
Version Uploaded Documentation Archive
0.2.0 Dec 16, 2017 Go to the documentation of scopify 0.2.0 Download scopify 0.2.0 archive
0.1.0 Sep 26, 2017 Go to the documentation of scopify 0.1.0 Download scopify 0.1.0 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
26 / 100
Code health derived from static analysis. [more]
98 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:scopify/scopify.dart.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use scopify.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
convert ^2.0.0 2.0.1
csslib ^0.14.1 0.14.1
html ^0.13.2 0.13.2+2
meta ^1.1.1 1.1.2
source_span ^1.4.0 1.4.0
uuid ^0.5.0 0.5.3
Transitive dependencies
args 1.3.0
charcode 1.1.1
collection 1.14.5
crypto 2.0.2+1
logging 0.11.3+1
path 1.5.1
typed_data 1.1.5
utf 0.9.0+4
Dev dependencies
test any