flippable_box 1.0.6

flippable_box #

FlippableBox is a double-sided Container, that holds two pieces of content and automatically re-sizes to match its content, whenever its flipped over.

Usage #

First import the package into your class:

import 'package:flippable_box/flippable_box.dart';

Create a FlippableBox with two child Containers. Change the isFlipped property to trigger the internal flip animation.

    onTap: () => setState(() => _isFlipped = !_isFlipped),
    child: FlippableBox(
        front: Container(width: 200, height: 200, color: Colors.white),
        back: Container(width: 300, height: 300, color: Colors.white),
        isFlipped: _isFlipped,

NOTE: It is required that the children are Containers, and have their size or constraints set manually, as shown in the example above. This is so the Box knows what its target size is when animating.

To control the flip animation, you can set duration, curve and flipVt which will cause the flip to be in the vertical axis rather than horizontal.

You can also specify a bg which takes a BoxDecoration, and a borderRadius in case you'd like to clip the child contents.

    front: child1,
    back: child2,
    isFlipped: _isFlipped,
    borderRadius: 32, //Uses a ClipRRect to clip contents of child containers
    bg: BoxDecoration(color: Colors.white), //Paints the box itself with a shared background
    duration: 0.5, //half second duration
    flipVt: true, //Flip vertically instead of horizontal
    curve: Curves.easeOut,

Example #

See the example directory for a simple example.

[1.0.3] Feb 12, 2020

  • Initial release.


import 'package:flippable_box/flippable_box.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      home: FlippableExample(),

class FlippableExample extends StatefulWidget {
  _FlippableExampleState createState() => _FlippableExampleState();

class _FlippableExampleState extends State<FlippableExample> with SingleTickerProviderStateMixin {
  bool _isFlipped = false;

  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.blue.shade100,
        body: Center(
          child: GestureDetector(
            onTap: () => setState(() => _isFlipped = !_isFlipped),
            child: FlippableBox(
              front: _buildCard("Front!", 250, 200, Colors.green),
              back: _buildCard("Back...", 350, 350, Colors.red),
              flipVt: true,
              isFlipped: _isFlipped,

  Widget _buildCard(String label, double width, double height, Color color) {
    return Container(
      color: color,
      width: width,
      height: height,
      child: Center(
        child: Text(label, style: TextStyle(fontSize: 32)),

Use this package as a library

1. Depend on it

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

  flippable_box: ^1.0.6

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:flippable_box/flippable_box.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Format lib/flippable_box.dart.

Run flutter format to format lib/flippable_box.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.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
Dev dependencies