real_ruler 0.0.3 copy "real_ruler: ^0.0.3" to clipboard
real_ruler: ^0.0.3 copied to clipboard

A ruler is a widget that displays a ruler with a given distance in cm or inches

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:real_ruler/real_ruler.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
        brightness: Brightness.dark,
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    const padding = SizedBox.square(dimension: 40);

    return Scaffold(
      appBar: AppBar(title: const Text("Rulers")),
      body: ListView(
        children: [
          Ruler.count(1.cm),

          /// 10 centimeters
          Ruler.count(10.cm),
          padding,

          /// 5 inches and 10 graduations per inch
          Ruler.count(5.inch(10)),
          padding,

          // 24 graduation of inch with 8 graduations
          Ruler.count(24.inchGraduation(8)),
          padding,

          // 4 graduation of inch with 8 graduations
          Ruler.count(4.inchGraduation(8)),
          padding,

          // 100 pixel each cm width
          Ruler.dynamic(100.cm),
          padding,

          // cm equalivlaint to real life ruler's cm
          Ruler.real(system: MeasureSystem.metric),
          padding,

          DynamicDoubleSidedRuler(
            cmWidth: 100,
            child: Container(
              width: 100,
              height: 100,
              color: Colors.red,
            ),
          ),
          padding,

          SizedBox(
            height: 100,
            child: DynamicDoubleSidedRuler(
              cmWidth: 100,
              rulersAxis: Axis.vertical,
              child: Container(
                width: 100,
                height: 100,
                color: Colors.red,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
2
likes
70
pub points
42%
popularity

Publisher

unverified uploader

A ruler is a widget that displays a ruler with a given distance in cm or inches

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

device_info_plus, flutter, freezed_annotation, json_annotation

More

Packages that depend on real_ruler