Movie Ticket Pass in Flutter

Movie Ticket Pass in Flutter :

Screenshot 1 :

Movie Ticket Pass in Flutter

Screenshot 2 :

Movie Ticket Pass in Flutter

Widget Package :

dash_separator.dart

import 'package:flutter/material.dart';

class DashSeparator extends StatelessWidget {

  const DashSeparator({this.height = 1, this.color = Colors.black});
  final double height;
  final Color color;

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constraints) {
        final double boxWidth = constraints.constrainWidth();
        const double dashWidth = 6.0;
        final double dashHeight = height;
        final int dashCount = (boxWidth / (1.5 * dashWidth)).floor();
        return Flex(
          children: List<Widget>.generate(dashCount, (_) {
            return SizedBox(
              width: dashWidth,
              height: dashHeight,
              child: DecoratedBox(
                decoration: BoxDecoration(color: color),
              ),
            );
          }),
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          direction: Axis.horizontal,
        );
      },
    );
  }
}

ticket_pass.dart

library ticket_pass_package;

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

import 'dash_separator.dart';

class TicketPass extends StatefulWidget {
  const TicketPass({
    this.width = 300,
    @required this.child,
    this.color = Colors.white,
    this.height = 200,
    this.elevation = 1.0,
    this.shadowColor = Colors.black,
    this.expandedHeight = 500,
    this.shouldExpand = false,
    this.curve = Curves.easeOut,
    this.animationDuration = const Duration(seconds: 1),
    this.alignment = Alignment.center,
    this.expandIcon = const CircleAvatar(
      maxRadius: 14,
      child: Icon(
        Icons.keyboard_arrow_down,
        color: Colors.white,
        size: 20,
      ),
    ),
    this.shrinkIcon = const CircleAvatar(
      maxRadius: 14,
      child: Icon(
        Icons.keyboard_arrow_up,
        color: Colors.white,
        size: 20,
      ),
    ),
    this.separatorHeight = 1.0,
    this.separatorColor = Colors.black,
    this.expansionTitle = const Text(
      'Purchased By',
      style: TextStyle(
        fontWeight: FontWeight.w600,
      ),
    ),
    this.titleColor = Colors.blue,
    this.titleHeight = 50.0,
    this.purchaserList,
    this.ticketTitle = const Text(
      'Sample title',
      style: const TextStyle(
        color: Colors.white,
        fontWeight: FontWeight.w600,
        fontSize: 18,
      ),
    ),
    this.expansionChild,
  });

  final double width;
  final double height;
  final double expandedHeight;
  final double elevation;
  final double titleHeight;
  final Widget child;
  final Color color;
  final Color shadowColor;
  final Color titleColor;
  final bool shouldExpand;
  final Curve curve;
  final Duration animationDuration;
  final Alignment alignment;
  final Widget expandIcon;
  final Widget shrinkIcon;
  final Color separatorColor;
  final double separatorHeight;
  final Text expansionTitle;
  final Text ticketTitle;
  final Widget expansionChild;
  final List<String> purchaserList;

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

class _TicketPassState extends State<TicketPass> {
  bool switcher = false;
  List<String> sample = <String>[
    'Sample 1',
    'Sample 2',
    'Sample 3',
    'Sample 4',
    'Sample 5',
    'Sample 6',
    'Sample 7',
    'Sample 8'
  ];

  Widget _myWidget() {
    if (switcher && widget.shouldExpand) {
      final ScrollController _scrollController = ScrollController();
      return ClipPath(
        clipper: ExtendedClipper(),
        child: Container(
          height: widget.expandedHeight,
          child: Column(
            children: <Widget>[
              widget.child,
              Padding(
                padding:
                    const EdgeInsets.symmetric(horizontal: 10.0, vertical: 5),
                child: InkWell(
                  onTap: () {
                    setState(() {
                      switcher = !switcher;
                    });
                  },
                  child: widget.shrinkIcon,
                ),
              ),
              DashSeparator(
                color: widget.separatorColor,
                height: widget.separatorHeight,
              ),
              const SizedBox(
                height: 10,
              ),
              widget.expansionTitle,
              widget.expansionChild != null
                  ? widget.expansionChild
                  : Expanded(
                      child: Container(
                        child: Padding(
                          padding: const EdgeInsets.symmetric(
                              horizontal: 20.0, vertical: 5),
                          child: Scrollbar(
                            child: FadingEdgeScrollView.fromScrollView(
                              gradientFractionOnEnd: 0.7,
                              gradientFractionOnStart: 0.5,
                              child: ListView(
                                controller: _scrollController,
                                children: widget.purchaserList != null
                                    ? widget.purchaserList
                                        .map<Widget>((String name) {
                                        return Container(
                                          child: Padding(
                                            padding: const EdgeInsets.symmetric(
                                                horizontal: 20.0, vertical: 5),
                                            child: ListTile(
                                                    leading: CircleAvatar(
                                                      child: Text(
                                                        name[0],
                                                      ),
                                                    ),
                                                    title: Text(
                                                      name,
                                                    ),
                                                  ),
                                          ),
                                        );
                                      }).toList()
                                    : sample.map<Widget>((String name) {
                                        return Container(
                                          child: Padding(
                                            padding: const EdgeInsets.symmetric(
                                                horizontal: 20.0, vertical: 5),
                                            child: ListTile(
                                                    leading: CircleAvatar(
                                                      child: Text(
                                                        name[0],
                                                      ),
                                                    ),
                                                    title: Text(
                                                      name,
                                                    ),
                                                  ),
                                          ),
                                        );
                                      }).toList(),
                              ),
                            ),
                          ),
                        ),
                      ),
                    ),
            ],
          ),
        ),
      );
    } else
      return ClipPath(
        clipper: TicketClipper(),
        child: Container(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              widget.child,
              Expanded(
                child: Container(),
              ),
              InkWell(
                onTap: () {
                  setState(() {
                    switcher = !switcher;
                  });
                },
                child: Align(
                  alignment: Alignment.bottomCenter,
                  child: Container(
                    height: widget.titleHeight,
                    decoration: BoxDecoration(
                      color: widget.titleColor,
                      borderRadius: const BorderRadius.only(
                        bottomLeft: Radius.circular(10),
                        bottomRight: Radius.circular(10),
                      ),
                    ),
                    child: Padding(
                      padding: const EdgeInsets.symmetric(
                          vertical: 8.0, horizontal: 20),
                      child: Row(
                        children: <Widget>[
                          Expanded(
                            child: widget.ticketTitle,
                          ),
                          widget.expandIcon,
                        ],
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      );
  }

  @override
  Widget build(BuildContext context) {
    return PhysicalShape(
      clipper: TicketClipper(),
      color: widget.color,
      elevation: widget.elevation,
      shadowColor: widget.shadowColor,
      child: AnimatedContainer(
        duration: widget.animationDuration,
        curve: widget.curve,
        width: widget.width,
        height: widget.shouldExpand
            ? switcher ? widget.expandedHeight : widget.height
            : widget.height,
        child: _myWidget(),
      ),
    );
  }
}

class TicketClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final Path path = Path();

    path.lineTo(0.0, 55);
    path.relativeArcToPoint(const Offset(0, 40),
        radius: const Radius.circular(10.0), largeArc: true);
    path.lineTo(0.0, size.height - 10);
    path.quadraticBezierTo(0.0, size.height, 10.0, size.height);
    path.lineTo(size.width - 10.0, size.height);
    path.quadraticBezierTo(
        size.width, size.height, size.width, size.height - 10);
    path.lineTo(size.width, 95);
    path.arcToPoint(Offset(size.width, 55),
        radius: const Radius.circular(10.0), clockwise: true);
    path.lineTo(size.width, 10.0);
    path.quadraticBezierTo(size.width, 0.0, size.width - 10.0, 0.0);
    path.lineTo(10.0, 0.0);
    path.quadraticBezierTo(0.0, 0.0, 0.0, 10.0);
    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}

class ExtendedClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final Path path = Path();

    path.lineTo(0.0, 55);
    path.relativeArcToPoint(const Offset(0, 40),
        radius: const Radius.circular(10.0), largeArc: true);
    path.lineTo(0.0, size.height - 10);
    path.quadraticBezierTo(0.0, size.height, 10.0, size.height);
    path.lineTo(size.width - 10.0, size.height);
    path.quadraticBezierTo(
        size.width, size.height, size.width, size.height - 10);
    path.lineTo(size.width, 95);
    path.arcToPoint(Offset(size.width, 55),
        radius: const Radius.circular(10.0), clockwise: true);
    path.lineTo(size.width, 10.0);
    path.quadraticBezierTo(size.width, 0.0, size.width - 10.0, 0.0);
    path.lineTo(10.0, 0.0);
    path.quadraticBezierTo(0.0, 0.0, 0.0, 10.0);

    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}

Outside All Package :

main.dart

import 'package:flutter/material.dart';
import 'widget/ticket_pass.dart';

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

class MyApp extends StatelessWidget {
  List<String> data = <String>[
    'Movie name',
    'Movie name',
    'Movie name',
    'Movie name'
  ];
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Ticket Pass Flutter',
        home: Scaffold(
            appBar: AppBar(
              title: Text('Movie Ticket Pass'),
            ),
            body: Center(
                child: TicketPass(
                    alignment: Alignment.center,
                    animationDuration: Duration(seconds: 2),
                   /* expansionChild: Expanded(
                        child: Container(
                      color: Colors.black,
                    )),*/
                    expandedHeight: 600,
                    expandIcon: CircleAvatar(
                        maxRadius: 14,
                        child: Icon(
                          Icons.keyboard_arrow_down,
                          color: Colors.white,
                          size: 20,
                        )),
                    expansionTitle: Text('Movie name',
                        style: TextStyle(
                          fontWeight: FontWeight.w600,
                        )),
                    purchaserList: data,
                    separatorColor: Colors.black,
                    separatorHeight: 2.0,
                    color: Colors.white,
                    curve: Curves.easeOut,
                    titleColor: Colors.blue,
                    shrinkIcon: Align(
                        alignment: Alignment.centerRight,
                        child: CircleAvatar(
                            maxRadius: 14,
                            child: Icon(
                              Icons.keyboard_arrow_up,
                              color: Colors.white,
                              size: 20,
                            ))),
                    ticketTitle: Text('Movie name',
                        style: const TextStyle(
                          color: Colors.white,
                          fontWeight: FontWeight.w600,
                          fontSize: 18,
                        )),
                    titleHeight: 50,
                    width: 350,
                    height: 220,
                    shadowColor: Colors.blue.withOpacity(0.5),
                    elevation: 8,
                    shouldExpand: true,
                    child: Padding(
                        padding: const EdgeInsets.symmetric(
                            horizontal: 30.0, vertical: 5),
                        child: Container(
                            height: 140,
                            child: Padding(
                                padding:
                                    const EdgeInsets.symmetric(vertical: 2.0),
                                child: Column(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceBetween,
                                    children: <Widget>[
                                      Expanded(
                                          child: Container(
                                              child: Row(children: <Widget>[
                                        Expanded(
                                            child: Column(
                                                mainAxisAlignment:
                                                    MainAxisAlignment
                                                        .spaceAround,
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.start,
                                                children: <Widget>[
                                              Text(
                                                'Movie Time',
                                                style: TextStyle(
                                                    color: Colors.black
                                                        .withOpacity(0.5)),
                                              ),
                                              Text(
                                                '12:00 PM',
                                                style: TextStyle(
                                                    fontWeight:
                                                        FontWeight.w600),
                                              )
                                            ])),
                                        Expanded(
                                            child: Column(
                                                mainAxisAlignment:
                                                    MainAxisAlignment
                                                        .spaceAround,
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.start,
                                                children: <Widget>[
                                              Text(
                                                'Name',
                                                style: TextStyle(
                                                  color: Colors.black
                                                      .withOpacity(0.5),
                                                ),
                                              ),
                                              Text('Movie name',
                                                  overflow:
                                                      TextOverflow.ellipsis,
                                                  maxLines: 1,
                                                  style: TextStyle(
                                                    fontWeight: FontWeight.w600,
                                                  ))
                                            ]))
                                      ]))),
                                      Expanded(
                                          child: Row(children: <Widget>[
                                        Expanded(
                                            child: Column(
                                                mainAxisAlignment:
                                                    MainAxisAlignment
                                                        .spaceAround,
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.start,
                                                children: <Widget>[
                                              Text(
                                                'Date',
                                                style: TextStyle(
                                                    color: Colors.black
                                                        .withOpacity(0.5)),
                                              ),
                                              Text(
                                                '4th Nov,2019 ',
                                                style: TextStyle(
                                                    fontWeight:
                                                        FontWeight.w600),
                                              )
                                            ])),
                                        Expanded(
                                            child: Column(
                                                mainAxisAlignment:
                                                    MainAxisAlignment
                                                        .spaceAround,
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.start,
                                                children: <Widget>[
                                              Text(
                                                'PRICE',
                                                style: TextStyle(
                                                    color: Colors.black
                                                        .withOpacity(0.5)),
                                              ),
                                              Text(
                                                '\$20 ',
                                                style: TextStyle(
                                                    fontWeight:
                                                        FontWeight.w600),
                                              )
                                            ]))
                                      ]))
                                    ]))))))));
  }
}

pubspec.yaml

name: flutter_ticket_pass
description: A new Flutter application.
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  fading_edge_scrollview:

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in