flip_panel 0.0.5

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

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.1]

  • Initial release.

[0.0.2]

  • Correct document

[0.0.3]

  • Fix bugs

[0.0.4]

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

[0.0.5]

  • re-config to support Dart2

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(),
      },
      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'),
          ),
        ],
      ),
    );
  }
}

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)),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flip_panel: ^0.0.5

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
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]
61
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Sep 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3
  • Flutter: 0.8.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

The description is too short.

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v0.1 release.

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Fix lib/flip_panel.dart.

Analysis of lib/flip_panel.dart reported 1 hint:

line 10 col 7: This class inherits from a class marked as @immutable, and therefore should be immutable (all instance fields must be final).

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
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test