flutter_stack_card 0.2.0+1

Flutter Stack Card #

Stack Card Widget is fastest way to create swap card in flutter.

Screenshots #

StackType.middle StackType.right

Usage #

StackCard.builder(
    itemCount: /* Item Count */,
    displayIndicator: /* Flag to display the indicator */,
    displayIndicatorBuilder: /* Customize the indicator */,
    onSwap: (index) {
        /* listen for swapping */
    },
    itemBuilder: (context, index) {
        /* item builder */
    }
)

Example #

Please find example in here: Example

0.2.0+1 - 23/07/2019 #

  • Specify flutter_slider_indicator plugin

0.2.0 - 23/07/2019 #

  • Add custom indicator package
  • Move indicator styling to model (Breaking)

0.1.0 - 22/07/2019 #

  • Develop stack card builder

example/lib/main.dart

import 'package:example/movie.dart';
import 'package:flutter/material.dart';
import 'package:flutter_stack_card/flutter_stack_card.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Stack Card',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Stack Card'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<Movie> _movieData = Movie().movieData;
  var width, height;

  @override
  Widget build(BuildContext context) {
    height = MediaQuery.of(context).size.height;
    width = MediaQuery.of(context).size.width;

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.only(top: 16.0),
        child: StackCard.builder(
          displayIndicator: true,
          displayIndicatorBuilder:
              IdicatorBuilder(displayIndicatorActiveColor: Colors.blue),
          itemCount: _movieData.length,
          onSwap: (index) {
            print("Page change to $index");
          },
          itemBuilder: (context, index) {
            Movie movie = _movieData[index];
            return _itemBuilder(movie);
          },
        ),
      ),
    );
  }

  Widget _itemBuilder(Movie movie) {
    return Container(
      child: Stack(children: <Widget>[
        Container(
          decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(12)),
              color: Colors.white),
        ),
        SingleChildScrollView(
          child: Column(
            children: <Widget>[
              Container(
                height: height * .3,
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(12)),
                    image: DecorationImage(
                        image: ExactAssetImage(movie.image),
                        fit: BoxFit.cover)),
              ),
              Container(
                height: height * .45,
                child: Padding(
                  padding:
                      const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisSize: MainAxisSize.max,
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: <Widget>[
                          Container(
                            width: 150,
                            child: Text(
                              movie.title,
                              style: TextStyle(
                                  color: Colors.blueGrey, fontSize: 24),
                              textAlign: TextAlign.left,
                            ),
                          ),
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.end,
                            children: <Widget>[
                              SizedBox(height: 4),
                              Text(
                                movie.display,
                                style:
                                    TextStyle(fontSize: 14, color: Colors.grey),
                                textAlign: TextAlign.right,
                              ),
                              SizedBox(height: 12),
                              Text(
                                "IMDB: ${movie.imdb.toString()}",
                                style: TextStyle(
                                    fontSize: 14, fontWeight: FontWeight.bold),
                                textAlign: TextAlign.right,
                              )
                            ],
                          ),
                        ],
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(vertical: 16),
                        child: Text(movie.gendres,
                            style: TextStyle(fontWeight: FontWeight.bold)),
                      ),
                      Expanded(
                        child: Padding(
                          padding: const EdgeInsets.only(bottom: 16, top: 8),
                          child: Text(movie.desc,
                              style: TextStyle(color: Colors.grey)),
                        ),
                      ),
                      Center(
                        child: IconButton(
                            icon: Icon(Icons.drag_handle, color: Colors.grey),
                            onPressed: () {}),
                      )
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
      ]),
    );
  }
}

Use this package as a library

1. Depend on it

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


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

We analyzed this package on Aug 18, 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.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_slider_indicator ^0.1.1 0.1.1
Transitive dependencies
collection 1.14.11 1.14.12
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