flutter_stories 0.2.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 80

flutter_stories #

example

Widget that brings stories mechanism to your apps

Advantages: #

  • Simple to use and intuitive API
  • Lightweight (~200 lines of code)
  • Feels familiar if you've used Instagram or Snapchat stories before
  • Can be used with Cupertino and Material packages independently

Usage #

Add flutter_stories to your pubspec.yaml

Example #

Full version can be found in example dir

showcase

Supported gestures #

  • Tap the right portion of the screen to switch to the next moment. You can specify onFlashForward callback to control app behavior in this case or when story finishes
  • Tap the left portion of the screen to switch to the previous moment. Similar to right tap, but uses onFlashBack
  • Long press (hold) the screen to hide the progress segments and pause story, release to show controls and unpause

API #

propertytyperequireddescription
momentCountinttrueSets the number of moments in story
momentDurationGetter(int index) => DurationtrueFunction that must return Duration for each moment
momentBuilder(BuildContext context, int index) => WidgettrueBuilder that gets executed for each moment
onFlashForward() => voidfalseGets executed when user taps the right portion of the screen on the last moment in story or when story finishes playing
onFlashBack() => voidfalseGets executed when user taps the left portion of the screen on the first moment in story
startAtintfalseDefaults to 0. Sets the index of the first moment that will be displayed
momentSwitcherFractiondoublefalseDefaults to 0.33. `sets the ratio of left and right tappable portions of the screen: left for switching back, right for switching forward
progressSegmentBuilder(BuildContext context, double progress, double gap) => WidgetfalseDefaults to Story.instagramProgressSegmentBuilder - Instagram-like minimalistic segment builder. Builder for each progress segment
progressSegmentGapdoublefalseDefaults to 2.0. Sets the gap between each progress segment
progressOpacityDurationDurationfalseDefaults to Duration(milliseconds: 300). Sets the duration for the progress bar show/hide animation
topOffsetdoublefalseDefaults to MediaQuery.of(context).padding.top. Sets the top offset of progress container
fullscreenboolfalseDefaults to true. If true hides the status bar via SystemChrome service

[0.2.1+1] - 22.04.2020 #

  • Added fullscreen param default value and assertion

[0.2.1] - 22.04.2020 #

  • Fixed fullscreen param initalization

[0.2.0] - 22.04.2020 #

  • Added topOffset param to control progress container offset from top of the screen
  • Added fullscreen param to control fullscreen behavior

[0.1.1] - 08.04.2020 #

  • onFlashForward and onFlashBack params are now optional
  • Refactoring

[0.1.0+1] - 16.07.2019 #

Fixed README

[0.1.0] - 16.07.2019 #

Initial release

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter_stories/flutter_stories.dart';

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

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      debugShowCheckedModeBanner: false,
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  final _momentCount = 5;
  final _momentDuration = const Duration(seconds: 5);

  @override
  Widget build(BuildContext context) {
    final images = List.generate(
      _momentCount,
      (idx) => Image.asset('assets/${idx + 1}.jpg'),
    );

    return CupertinoPageScaffold(
      child: Center(
        child: Container(
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(32.0),
            border: Border.all(
              color: CupertinoColors.activeOrange,
              width: 2.0,
              style: BorderStyle.solid,
            ),
          ),
          width: 64.0,
          height: 64.0,
          padding: const EdgeInsets.all(2.0),
          child: GestureDetector(
            onTap: () {
              showCupertinoDialog(
                context: context,
                builder: (context) {
                  return CupertinoPageScaffold(
                    child: Story(
                      onFlashForward: Navigator.of(context).pop,
                      onFlashBack: Navigator.of(context).pop,
                      momentCount: 5,
                      momentDurationGetter: (idx) => _momentDuration,
                      momentBuilder: (context, idx) => images[idx],
                    ),
                  );
                },
              );
            },
            child: Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(28.0),
                color: CupertinoColors.activeBlue,
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [flutter_stories] that is in a package requiring null.

Maintenance suggestions

The package description is too short. (-11 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test