smoothie 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

pub package

smoothie #

Create and sample a smooth bezier curve going through a given set of points

Usage #

Let's say you have some arbitrary data (a list of points):

var _originalDataSeries = <Point>[
    Point(0, 5),
    Point(3, 15),
    Point(5, 10),
    Point(6, 6),
    Point(9, 13),
  ];

Define a number of sampling points per original point:

int _samplesPerPoint = 10;

Create a smooth curve:

var _sampledCurve = Smoothie().getSampledCurve(_samplesPerPoint, _originalDataSeries);

See oversampling in action:

[0.1.4] - 2020-05-12 #

Updated example #

[0.1.3] - 2020-05-12 #

Improved documentation #

[0.1.2] - 2020-05-04 #

Updated the example #

[0.1.1] - 2020-05-04 #

Separate extension for list of custom data points #

[0.1.0] - 2020-05-04 #

Breaking change - using extension methods #

[0.0.4] - 2020-05-02 #

Improved naming and documentation #

[0.0.3] - 2020-04-23 #

Improved Readme example #

[0.0.2] - 2020-04-01 #

Added the example app #

[0.0.1] - 2020-03-31 #

Initial release #

example/lib/main.dart

import 'dart:math';

import 'package:charts_flutter/flutter.dart' as charts;
import 'package:flutter/material.dart';
import 'package:smoothie/smoothie.dart';

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

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

class SmoothieHomePage extends StatefulWidget {
  SmoothieHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _SmoothieHomePageState createState() => _SmoothieHomePageState();
}

class _SmoothieHomePageState extends State<SmoothieHomePage> {
  int _samplesPerPoint = 0;

  var originalDataSeries = <Point>[
    Point(0, 5),
    Point(3, 15),
    Point(5, 10),
    Point(6, 6),
    Point(9, 13),
  ];

  @override
  void initState() {
    super.initState();
    _samplesPerPoint = 10;
  }

  void _incrementCounter() {
    setState(() {
      _samplesPerPoint++;
    });
  }

  void _decrementCounter() {
    setState(() {
      if (_samplesPerPoint > 1) _samplesPerPoint--;
    });
  }

  @override
  Widget build(BuildContext context) {
    var series = [
      new charts.Series(
        domainFn: (Point chartData, _) => chartData.x / _samplesPerPoint,
        measureFn: (Point chartData, _) => chartData.y,
        colorFn: (Point point, _) => charts.MaterialPalette.teal.shadeDefault,
        id: 'Example Series',
        data: originalDataSeries.getSampledCurveFromPoints(
          _samplesPerPoint,
        ),
      ),
    ];

    var chart = new charts.LineChart(
      series,
      animate: false,
      defaultRenderer: new charts.LineRendererConfig(
        includeArea: true,
      ),
    );

    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                'The curve now has $_samplesPerPoint sampling points per original point.',
              ),
              Container(
                height: 200,
                child: chart,
              ),
            ],
          ),
        ),
        floatingActionButton: Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            FloatingActionButton(
              onPressed: _decrementCounter,
              tooltip: 'Decrement',
              child: Icon(Icons.remove),
            ),
            FloatingActionButton(
              onPressed: _incrementCounter,
              tooltip: 'Increment',
              child: Icon(Icons.add),
            ),
          ],
        ));
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  smoothie: ^0.1.4

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:smoothie/smoothie.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
25
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • smoothie that is a package requiring null.

Health suggestions

Format lib/smoothie.dart.

Run flutter format to format lib/smoothie.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
bezier ^1.1.5 1.1.5
flutter 0.0.0
vector_math ^2.0.8 2.0.8 2.1.0-nullsafety
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
Dev dependencies
flutter_test