ribbon 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 77

ribbon #

A Ribbon decoration on a widget.

use a Ribbon to decorate a Widget such as container,card...etc.

no clip apply to ribbon title,so check the title length

Installing:

In your pubspec.yaml

dependencies:

ribbon: ^0.0.1

Example Usage:

import 'package:ribbon/ribbon.dart';

Ribbon(

nearLength: nearLength,

farLength: farLength,

title: 'New!',

titleStyle: TextStyle(

color: Colors.greenAccent,

fontSize: 18,

fontWeight: FontWeight.bold),

color: Colors.redAccent,

location: location,

child: )

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/lib/main.dart

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

void main() {
  runApp(MaterialApp(
    title: "ribbon demo",
    theme: ThemeData.light(),
    home: DemoPage(),
    // debugShowMaterialGrid:true,
    debugShowCheckedModeBanner: false,
  ));
}

class DemoPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _DemoPageState();
}

class _DemoPageState extends State<DemoPage> {
  double nearLength = 80;
  double farLength = 120;
  Color color = Colors.redAccent;
  RibbonLocation location = RibbonLocation.topStart;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Ribbon Demo'),
      ),
      body: Center(
        child: Column(mainAxisAlignment: MainAxisAlignment.center,
            // crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Ribbon(
                nearLength: nearLength,
                farLength: farLength,
                title: 'New!',
                titleStyle: TextStyle(
                    color: Colors.greenAccent,
                    fontSize: 18,
                    fontWeight: FontWeight.bold),
                color: Colors.redAccent,
                location: location,
                child: Container(
                    width: 300,
                    height: 160,
                    color:Colors.blueAccent,
                    child: Center(
                        child: Text(
                      'hello ribbon',
                      style: TextStyle(color: Colors.white, fontSize: 20),
                    ))),
              ),
              SizedBox(
                height: 16,
              ),
              Text(
                'RibbonLocation:',
                style: TextStyle(color: Colors.black),
              ),
              Row(
                mainAxisSize: MainAxisSize.min,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  _buildRadio('topStart', RibbonLocation.topStart),
                  _buildRadio('topEnd', RibbonLocation.topEnd),
                ],
              ),
              Row(
                mainAxisSize: MainAxisSize.min,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  _buildRadio('bottomStart', RibbonLocation.bottomStart),
                  _buildRadio('bottomEnd', RibbonLocation.bottomEnd),
                ],
              ),
              Row(
                mainAxisSize: MainAxisSize.min,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text('nearLength:'),
                  Slider(
                    value: nearLength,
                    onChanged: (double value) {
                      setState(() {
                        nearLength = value;
                      });
                    },
                    label: 'nearLength',
                    min: 0,
                    max: 280,
                  ),
                ],
              ),
              Row(
                mainAxisSize: MainAxisSize.min,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text('farLength:'),
                  Slider(
                    value: farLength,
                    onChanged: (double value) {
                      setState(() {
                        farLength = value;
                      });
                    },
                    label: 'nearLength',
                    min: 20,
                    max: 300,
                  ),
                ],
              ),
            ]),
      ),
    );
  }

  _buildRadio(String text, RibbonLocation value) {
    return Row(
      children: <Widget>[
        Text(text),
        Radio<RibbonLocation>(
            value: value,
            groupValue: location,
            onChanged: (RibbonLocation value) {
              setState(() {
                location = value;
              });
            }),
      ],
    );
  }
}

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health suggestions

Fix lib/ribbon.dart. (-1.49 points)

Analysis of lib/ribbon.dart reported 3 hints:

line 300 col 12: Name non-constant identifiers using lowerCamelCase.

line 300 col 23: Name non-constant identifiers using lowerCamelCase.

line 300 col 34: Name non-constant identifiers using lowerCamelCase.

Maintenance suggestions

Package is getting outdated. (-34.79 points)

The package was last published 70 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.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