flip_panel 0.0.8

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 86

Flip Panel #

pub package Build Status

A package for flip panel with built-in animation

How to use #

import 'package:flip_panel/flip_panel.dart';

Create a flip panel from iterable source:

final digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

FlipPanel.builder(
    itemBuilder: (context, index) => Container(
       color: Colors.black,
       padding: const EdgeInsets.symmetric(horizontal: 6.0),
       child: Text(
         '${digits[index]}',
         style: TextStyle(
             fontWeight: FontWeight.bold,
             fontSize: 50.0,
             color: Colors.white),
       ),
     ),
    itemsCount: digits.length,
    period: const Duration(milliseconds: 1000),
    loop: 1,
)

Create a flip panel from stream source:

FlipPanel<int>.stream(
      itemStream: Stream.periodic(Duration(milliseconds: 1000), (count) => count % 10),
      itemBuilder: (context, value) => Container(
        color: Colors.black,
        padding: const EdgeInsets.symmetric(horizontal: 6.0),
        child: Text(
          '$value',
          style: TextStyle(
            fontWeight: FontWeight.bold,
            fontSize: 50.0,
            color: Colors.white
          ),
        ),
      ),
      initValue: 0,
  );

[0.0.8] - 2018-10-20

  • Fix typo

[0.0.7] - 2018-10-19

  • Fix small analysis error.

[0.0.6] - 2018-10-19

  • add countdown clock

[0.0.5] - 2018-08-11

  • re-config to support Dart2

[0.0.4] - 2018-06-28

  • Fix bugs (temporarily get around the matter of perspective transform)

[0.0.3] - 2018-06-21

  • Fix bugs

[0.0.2] - 2018-06-20

  • Correct document

[0.0.1] - 2018-06-19

  • Initial release.

example/lib/main.dart

import 'package:flip_panel/flip_panel.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:math';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.light().copyWith(
            scaffoldBackgroundColor: Colors.white,
          ),
      title: 'FlipPanel',
      routes: {
        'flip_image': (_) => AnimatedImagePage(),
        'flip_clock': (_) => FlipClockPage(),
        'countdown_clock': (_) => CountdownClockPage(),
      },
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('FlipPanel'),
      ),
      body: Column(
        children: [
          ListTile(
            title: Text('FlipImage'),
            onTap: () => Navigator.of(context).pushNamed('flip_image'),
          ),
          ListTile(
            title: Text('FlipClock'),
            onTap: () => Navigator.of(context).pushNamed('flip_clock'),
          ),
          ListTile(
            title: Text('CountdownClock'),
            onTap: () => Navigator.of(context).pushNamed('countdown_clock'),
          ),
        ],
      ),
    );
  }
}

class AnimatedImagePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    final imageWidth = 320.0;
    final imageHeight = 171.0;
    final toleranceFactor = 0.033;
    final widthFactor = 0.125;
    final heightFactor = 0.5;

    final random = Random();

    return Scaffold(
      appBar: AppBar(
        title: Text('FlipImage'),
      ),
      body: Container(
        child: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Row(
                mainAxisSize: MainAxisSize.min,
                children: [0, 1, 2, 3, 4, 5, 6, 7,].map((count) =>
                    FlipPanel.stream(
                      itemStream: Stream.fromFuture(
                          Future.delayed(Duration(milliseconds: random.nextInt(20) * 100), () => 1)
                      ),
                      itemBuilder: (_, value) =>
                        value <= 0
                          ? Container(
                              color: Colors.white,
                              width: widthFactor * imageWidth,
                              height: heightFactor * imageHeight,
                            )
                          : ClipRect(
                              child: Align(
                                alignment: Alignment(-1.0 + count * 2 * 0.125 + count * toleranceFactor, -1.0),
                                widthFactor: widthFactor,
                                heightFactor: heightFactor,
                                child: Image.asset(
                                  'assets/flutter_cover.png',
                                  width: imageWidth,
                                  height: imageHeight,
                                )
                              )
                          ),
                      initValue: 0,
                      spacing: 0.0,
                )).toList(),
              ),
              Row(
                mainAxisSize: MainAxisSize.min,
                children: [0, 1, 2, 3, 4, 5, 6, 7,].map((count) =>
                    FlipPanel.stream(
                      itemStream: Stream.fromFuture(
                          Future.delayed(Duration(milliseconds: random.nextInt(20) * 100), () => 1)
                      ),
                      itemBuilder: (_, value) =>
                      value <= 0
                          ? Container(
                              color: Colors.white,
                              width: widthFactor * imageWidth,
                              height: heightFactor * imageHeight,
                            )
                          : ClipRect(
                              child: Align(
                                alignment: Alignment(-1.0 + count * 2 * 0.125 + count * toleranceFactor, 1.0),
                                widthFactor: widthFactor,
                                heightFactor: heightFactor,
                                child: Image.asset(
                                  'assets/flutter_cover.png',
                                  width: imageWidth,
                                  height: imageHeight,
                                )
                          )
                      ),
                      initValue: 0,
                      spacing: 0.0,
                      direction: FlipDirection.down,
                    )).toList(),
              )
            ],
          ),
        ),
      ),
    );
  }
}

class FlipClockPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('FlipClock'),
      ),
      body: Container(
        child: Center(
          child: FlipClock.simple(
            startTime: DateTime.now(),
            digitColor: Colors.white,
            backgroundColor: Colors.black,
            digitSize: 48.0,
            borderRadius: const BorderRadius.all(Radius.circular(3.0)),
          ),
        ),
      ),
    );
  }
}

class CountdownClockPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('FlipClock'),
      ),
      body: Container(
        child: Center(
          child: FlipClock.countdown(
            duration: Duration(minutes: 1),
            digitColor: Colors.white,
            backgroundColor: Colors.black,
            digitSize: 48.0,
            borderRadius: const BorderRadius.all(Radius.circular(3.0)),
            onDone: () => print('ih'),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flip_panel: ^0.0.8

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flip_panel/flip_panel.dart';
  
Version Uploaded Documentation Archive
1.0.0 Feb 9, 2019 Go to the documentation of flip_panel 1.0.0 Download flip_panel 1.0.0 archive
0.0.9 Nov 27, 2018 Go to the documentation of flip_panel 0.0.9 Download flip_panel 0.0.9 archive
0.0.8 Oct 20, 2018 Go to the documentation of flip_panel 0.0.8 Download flip_panel 0.0.8 archive
0.0.6 Oct 19, 2018 Go to the documentation of flip_panel 0.0.6 Download flip_panel 0.0.6 archive
0.0.5 Aug 11, 2018 Go to the documentation of flip_panel 0.0.5 Download flip_panel 0.0.5 archive
0.0.4 Jun 28, 2018 Go to the documentation of flip_panel 0.0.4 Download flip_panel 0.0.4 archive
0.0.3 Jun 21, 2018 Go to the documentation of flip_panel 0.0.3 Download flip_panel 0.0.3 archive
0.0.2 Jun 19, 2018 Go to the documentation of flip_panel 0.0.2 Download flip_panel 0.0.2 archive
0.0.1 Jun 19, 2018 Go to the documentation of flip_panel 0.0.1 Download flip_panel 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
82
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
78
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.13
  • Flutter: 1.2.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/flip_panel.dart. (-1.99 points)

Analysis of lib/flip_panel.dart reported 4 hints:

line 7 col 29: Name non-constant identifiers using lowerCamelCase.

line 10 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: FlipClock._digitBuilder, FlipClock._separator

line 207 col 35: Name non-constant identifiers using lowerCamelCase.

line 210 col 37: Name non-constant identifiers using lowerCamelCase.

Maintenance suggestions

The package description is too short. (-12 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 >=1.20.1 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test