floating_ribbon 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

Floating Ribbon #

Build Status

A new Flutter package for creating floating ribbons on images.

Dependency #

dependencies:
  floating_ribbon: any

How To Use #

In order to achieve the shimmering effect, you need to add a package in pubspec.yaml.

dependencies:
  skeleton_text: any

The code to reproduce it,

import 'package:skeleton_text/skeleton_text.dart';
import 'package:floating_ribbon/floating_ribbon.dart';
FloatingRibbon(
  height: 85,
  width: 85,
  childHeight: 75,
  childWidth: 75,
  child: Padding(
    padding: const EdgeInsets.all(8.0),
    child: FlutterLogo(),
  ),
  childDecoration: BoxDecoration(color: Colors.grey),
  ribbon: SkeletonAnimation(
    child: Center(
      child: Text(
        'Exclusive',
        style: TextStyle(
          color: Colors.white,
        ),
        textAlign: TextAlign.center,
      ),
    ),
  ),
  shadowHeight: 5,
);

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.

[1.0.1] - 16/08/2019 #

  • Modified README.md

[1.0.0] - 16/08/2019 #

  • Added Example
  • Added Documentation

[0.0.1] - 16/08/2019 #

  • Initial Release

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomePage(),
      debugShowMaterialGrid: false,
      debugShowCheckedModeBanner: false,
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  List<String> _hotels = [
    'Samudra Hotel',
    'Naivedyam',
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[200],
      appBar: AppBar(
        title: Text('Floating Ribbon Example'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          children: <Widget>[
            Container(
              color: Colors.white,
              height: 40,
              width: MediaQuery.of(context).size.width,
              child: Center(
                child: Text(
                  'clipper = Clipper.right',
                  style: TextStyle(
                    color: Colors.black54,
                    fontSize: 20,
                  ),
                  textAlign: TextAlign.center,
                ),
              ),
            ),
            ListView(
              shrinkWrap: true,
              children: <Widget>[
                restaurantListTile(_hotels.elementAt(0), true),
                restaurantListTile(_hotels.elementAt(1), true),
              ],
            ),
            Container(
              color: Colors.white,
              height: 40,
              width: MediaQuery.of(context).size.width,
              child: Center(
                child: Text(
                  'clipper = Clipper.equilateral',
                  style: TextStyle(
                    color: Colors.black54,
                    fontSize: 20,
                  ),
                  textAlign: TextAlign.center,
                ),
              ),
            ),
            ListView(
              shrinkWrap: true,
              children: <Widget>[
                restaurantListTile(_hotels.elementAt(0), false),
                restaurantListTile(_hotels.elementAt(1), false),
              ],
            ),
          ],
        ),
      ),
    );
  }

  Widget restaurantListTile(String hotel, bool isRight) {
    double width = MediaQuery.of(context).size.width;
    width = width * 0.30;

    return Container(
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(
          Radius.circular(10.0),
        ),
        color: Colors.white70,
      ),
      margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
      child: Container(
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            FloatingRibbon(
              height: 85,
              width: 85,
              childHeight: 75,
              childWidth: 75,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: FlutterLogo(),
              ),
              childDecoration: BoxDecoration(color: Colors.grey),
              ribbon: Center(
                child: Text(
                  'Exclusive',
                  style: TextStyle(
                    color: Colors.white,
                  ),
                  textAlign: TextAlign.center,
                ),
              ),
              clipper: isRight ? Clipper.right : Clipper.equilateral,
              equilateralTriangleWidth: isRight ? null : 5,
              shadowHeight: 7,
            ),
            Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisSize: MainAxisSize.max,
              children: <Widget>[
                Padding(
                  padding: const EdgeInsets.only(left: 15.0, bottom: 5.0),
                  child: Container(
                    width: MediaQuery.of(context).size.width * 0.6,
                    child: Text(
                      hotel,
                      style: TextStyle(
                        color: Colors.black,
                        fontSize: 15,
                        fontWeight: FontWeight.bold,
                        fontFamily: 'Avenir-Bold',
                      ),
                      maxLines: 3,
                    ),
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(left: 15.0),
                  child: Row(
                    children: <Widget>[
                      Padding(
                        padding: const EdgeInsets.only(right: 5.0),
                        child: Icon(Icons.access_alarms,
                            color: Colors.black54, size: 20),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(top: 2.5),
                        child: Text(
                          "30 min",
                          style: TextStyle(
                            color: Colors.black45,
                            fontFamily: 'Avenir-Black',
                            fontSize: 13,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(
                          left: 5.0,
                          right: 5.0,
                          top: 3.0,
                        ),
                        child: Icon(
                          Icons.fiber_manual_record,
                          color: Colors.black54,
                          size: 8.0,
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(top: 3.5),
                        child: Text(
                          'Open',
                          style: TextStyle(
                            color: Colors.green,
                            fontFamily: 'Avenir-Black',
                            fontWeight: FontWeight.w700,
                            fontSize: 13,
                          ),
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(
                            left: 5.0, right: 5.0, top: 3.0),
                        child: Icon(Icons.fiber_manual_record,
                            color: Colors.black54, size: 8.0),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(top: 3.0),
                        child: Text(
                          '\$\$',
                          style: TextStyle(
                            color: Colors.black54,
                            fontSize: 13,
                            fontWeight: FontWeight.w900,
                          ),
                        ),
                      )
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  floating_ribbon: ^1.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:floating_ribbon/floating_ribbon.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
58
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]
79
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.7
  • Flutter: 1.12.13+hotfix.9

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 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