range_fix 0.1.2+1

  • README.md
  • Example
  • Installing
  • Versions
  • 30


A workaround for the Range.getClientRects bug in Chrome. A dart port of rangefix.


A simple usage example:

final range = window.getSelection().getRangeAt(0);

final rects = RangeFix.getClientRects(range);
for (final rect in rects) {
  // Do whatever you want.

Features and bugs

Please file feature requests and bugs at the issue tracker.



  • Change the repo URL.


  • Fix a type error which occurs in checked mode.


  • Sort the rects of getClientRects() in content order


  • Initial version


// Copyright (c) 2015, Kwang Yul Seo. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library range_fix.example;

import 'dart:html';
import 'dart:math';

import 'package:color/color.dart';
import 'package:range_fix/range_fix.dart';

final Random randomGen = new Random();

String randomColor() {
  final r = randomGen.nextInt(256);
  final g = randomGen.nextInt(256);
  final b = randomGen.nextInt(256);
  return new RgbColor(r, g, b).toCssString();

void renderRects(List<Rectangle> rects) {
  for (final rect in rects) {
    final element = new DivElement();
      ..backgroundColor = randomColor()
      ..opacity = '0.5'
      ..position = 'fixed'
      ..top = new Dimension.px(rect.top).toString()
      ..left = new Dimension.px(rect.left).toString()
      ..width = new Dimension.px(rect.width).toString()
      ..height = new Dimension.px(rect.height).toString();

void main() {
  querySelector('#broken').innerHtml = '${isGetClientRectsBroken()}';

  final p1 = querySelector('#p1');
  final p2 = querySelector('#p2');
  final p3 = querySelector('#p3');
  final p4 = querySelector('#p4');

  final beforeRange = new Range()
    ..setStart(p1.firstChild, 3)
    ..setEnd(p2.firstChild, 3);

  final afterRange = new Range()
    ..setStart(p3.firstChild, 3)
    ..setEnd(p4.firstChild, 3);


Use this package as a library

1. Depend on it

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

  range_fix: "^0.1.2+1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

      import 'package:range_fix/range_fix.dart';
Version Uploaded Documentation Archive
0.1.2+1 Mar 7, 2016 Go to the documentation of range_fix 0.1.2+1 Download range_fix 0.1.2+1 archive
0.1.2 Mar 7, 2016 Go to the documentation of range_fix 0.1.2 Download range_fix 0.1.2 archive
0.1.1 Nov 25, 2015 Go to the documentation of range_fix 0.1.1 Download range_fix 0.1.1 archive
0.1.0 Nov 23, 2015 Go to the documentation of range_fix 0.1.0 Download range_fix 0.1.0 archive


We analyzed this package on May 22, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.54.0
  • pana: 0.11.1


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


Detected platforms: web

Primary library: package:range_fix/range_fix.dart with components: html.


  • 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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0
Dev dependencies
browser any
color any
test >=0.12.0 <0.13.0