showcase 0.6.0

Showcase

Pub Package CircleCI

Generate documentation screenshots of your widgets.


Installation #

Add the following to your pubspec.yaml file:

dev_dependencies:
  showcase: <1.0.0

then run:

flutter packages get

Then you can either annotate the widgets you want to have showcased or manually create a test file with multiple widgets:

With annotations #

Add another dependency to your pubspec.yaml file:

dev_dependencies:
  build_runner: ^1.2.8

Just annotate the widgets you want with @Showcased:

import 'package:showcase/showcase.dart';

@Showcased()
class MyWidget extends StatelessWidget {
  // ...
}

The builder will generate a .showcased_test.dart test file for each annotated class file. Just run:

flutter packages pub run build_runner build

Manually testing #

Create a test file with the following:

import 'package:flutter_test/flutter_test.dart';
import 'package:showcase/showcase.dart';

void main() {
  group('Showcase!', () {
    showcaseWidgets([]);
  });
}

Replace the empty list with a collection of widgets. showcaseWidgets also have some options you can tweak.

Then it's just a matter of running flutter test and have your screenshots generated on ./showcase/ (or another output directory you had configured).

Example showcase #

The example app provided generates the following showcase image:

CHANGELOG #

0.6.0 #

  • Make @Showcased annotation receive optional wrapping container size.

0.5.1 #

  • Consider named parameters when querying for required.

0.5.0 #

  • Use forDesignTime when default constructor has required parameters.

In order to be showcased, the @showcased widget class must have a default constructor with no required parameters without default values OR define a forDesignTime() factory constructor. The reason for this is that widgets are usually created with context specific constructor parameters. When rendering the preview of the widget, we don’t necessarily know the right values for these parameters. So, we let the user to provide them for us via this specially named constructor.

0.4.1 #

  • Remove unused import.

0.4.0 #

  • Load custom fonts (defined in project pubspec.yaml) aside from Roboto before showcasing.

0.3.0 #

  • Make showcased widgets display fonts.

Following https://github.com/flutter/flutter/issues/17700, it's now possible to display fonts on golden files, so it is on showcase as well.

Showcase will use the Roboto font by trying to locate it on the filesystem package cache folder, or downloading it from the internet.

0.2.0 #

0.1.0 #

  • Beta. Use with caution, lots of missing features.

example/README.md

showcase_example #

This example demonstrates how to use showcase in your projects.

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (analyzer, dart_style).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
analyzer ^0.35.0 0.35.4 0.37.0
build ^1.1.2 1.1.5
dart_style ^1.2.4 1.2.4 1.2.9
flutter 0.0.0
flutter_test 0.0.0
glob ^1.1.7 1.1.7
http ^0.12.0+1 0.12.0+2
source_gen ^0.9.4+1 0.9.4+3
yaml ^2.1.15 2.1.16
Transitive dependencies
args 1.5.2
async 2.2.0 2.3.0
boolean_selector 1.0.4 1.0.5
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
front_end 0.1.14 0.1.20
http_parser 3.1.3
kernel 0.3.14 0.3.20
logging 0.11.3+2
matcher 0.12.5
meta 1.1.6 1.1.7
package_config 1.0.5
path 1.6.2
pedantic 1.7.0 1.8.0+1
pub_semver 1.4.2
quiver 2.0.3
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.4
term_glyph 1.1.0
test_api 0.2.5 0.2.6
typed_data 1.1.6
vector_math 2.0.8
watcher 0.9.7+12
Dev dependencies
test ^1.0.0

Admin