content_placeholder 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 86

Content Placeholder #

Version Build Status Code Size License

A fluter plugin to make nice animated shimmer content placeholders. This plugin uses shimmer flutter plugin for shimmer animation.

How To Use #

ContentPlaceholder();

Getting Started #

See the example directory for a complete sample app.

Example App

Changelog #

Refer to the Changelog to get all release notes.

Issues & Feedback #

Please file issues, bugs, or feature requests in the repository issue tracker.

Contributions are welcome 😊❤️

[0.1.0] - 13 December 2019 #

  • Block spacing issues fixed.
  • Example app code updated.

[0.0.2] - 12 December 2019 #

Initial release, should be polished.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:content_placeholder/content_placeholder.dart';

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

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SafeArea(
          child: SingleChildScrollView(
            child: Padding(
              padding: EdgeInsets.all(20),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: <Widget>[
                  SectionHolder(
                    label: 'Normal',
                    placeholder: ContentPlaceholder(),
                  ),
                  SectionHolder(
                    label: 'Without Animation',
                    placeholder: ContentPlaceholder(
                      isAnimationEnabled: false,
                    ),
                  ),
                  SectionHolder(
                    label: 'Height & Width',
                    placeholder: ContentPlaceholder(
                      height: 50,
                      width: 150,
                    ),
                  ),
                  Builder(builder: (context) {
                    return SectionHolder(
                      label: 'Grouped',
                      placeholder: ContentPlaceholder(
                        context: context,
                        child: Column(
                          children: <Widget>[
                            Row(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: <Widget>[
                                ContentPlaceholder.block(
                                  width: 100,
                                  height: 100,
                                  rightSpacing: 10,
                                ),
                                Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    ContentPlaceholder.block(
                                      width:
                                          MediaQuery.of(context).size.width - 150,
                                      height: 25,
                                    ),
                                    ContentPlaceholder.block(
                                      width: MediaQuery.of(context).size.width / 2,
                                      height: 25,
                                    ),
                                    ContentPlaceholder.block(
                                      width: 80,
                                      height: 30,
                                    ),
                                  ],
                                ),
                              ],
                            ),
                          ],
                        ),
                      ),
                    );
                  }),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

class SectionHolder extends StatelessWidget {
  final String label;
  final ContentPlaceholder placeholder;

  SectionHolder({
    @required this.placeholder,
    @required this.label,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Text(this.label, style: Theme.of(context).textTheme.headline),
        SizedBox(height: 10),
        this.placeholder,
        SizedBox(height: 20),
      ],
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  content_placeholder: ^0.1.0

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:content_placeholder/content_placeholder.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
71
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]
86
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
shimmer ^1.0.1 1.1.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