ruler_picker 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

ruler_picker 标尺选择器 #

This is a picker with ruler style for flutter.

标尺样式来选择数字,支持自定义 marker

demo 演示 #

demo

Usage 使用方法 #

RulerPicker(
  controller: _rulerPickerController,
  onValueChange: (value) {
    setState(() {
      _textEditingController.text = value.toString();
    });
  },
  width: 300,
  height: 100,
),

Example 示例代码 #

./example 文件夹

[0.1.1] - 完善说明 #

完善说明

[0.1.0] - bugfix #

bugfix

[0.0.2] - bugfix #

bugfix

[0.0.1] - First Version 初始版本 #

The first version of this package.

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ruler_picker/ruler_picker.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Ruler Picker Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Ruler Picker Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  RulerPickerController _rulerPickerController;
  TextEditingController _textEditingController;
  num showValue = 0;

  @override
  void initState() {
    super.initState();
    _rulerPickerController = RulerPickerController(value: 0);
    _textEditingController = TextEditingController(text: '10');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            // a ruler picker
            RulerPicker(
              controller: _rulerPickerController,
              onValueChange: (value) {
                setState(() {
                  _textEditingController.text = value.toString();
                });
              },
              width: 300,
              height: 100,
            ),
            // a text field to sync the value of the ruler picker
            Container(
              margin: EdgeInsets.only(top: 20),
              width: 300,
              child: CupertinoTextField(
                controller: _textEditingController,
                onChanged: (value) {
                  showValue = int.parse(value);
                },
                onEditingComplete: () {
                  _rulerPickerController.value = showValue;
                },
              ),
            )
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  ruler_picker: ^0.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:ruler_picker/ruler_picker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

We analyzed this package on Jun 5, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev
  • Flutter: 1.17.1

Health suggestions

Fix lib/ruler_picker.dart. (-2.48 points)

Analysis of lib/ruler_picker.dart reported 5 hints:

line 49 col 7: This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: RulerPicker._value, RulerPicker.fractionDigits, RulerPicker.controller

line 138 col 38: The member 'notifyListeners' can only be used within instance members of subclasses of 'package:flutter/src/foundation/change_notifier.dart'.

line 138 col 38: The member 'notifyListeners' can only be used within 'package:flutter/src/foundation/change_notifier.dart' or a test.

line 231 col 20: Avoid using braces in interpolation when not needed.

line 234 col 23: Avoid using braces in interpolation when not needed.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test