import 'package:flip_card/flip_card.dart';
import 'package:flutter/material.dart';
// main function calling
// to the MyFlipCard class.
void main() {
runApp(MyFlipCard());
}
// Class MyFlipCard is stateful class.
class MyFlipCard extends StatefulWidget {
const MyFlipCard({Key? key}) : super(key: key);
@override
State<MyFlipCard> createState() => _MyFlipCardState();
}
class _MyFlipCardState extends State<MyFlipCard> {
@override
Widget build(BuildContext context) {
// returning MaterialApp
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text("Flip Card"),
),
// body has a center with row child.
body: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Flipcard with vertical
// direction when flip
FlipCard(
direction: FlipDirection.VERTICAL,
// front of the card
front: Container(
alignment: Alignment.center,
width: 200,
height: 200,
color: Colors.red,
child: Text("Front"),
),
// back of the card
back: Container(
alignment: Alignment.center,
width: 200,
height: 200,
color: Colors.teal,
child: Text("Back"),
),
),
SizedBox(width: 30,),
// 2nd card showing Horizontal FlipDirection
FlipCard(
direction: FlipDirection.HORIZONTAL,
// front of the card
front: Container(
alignment: Alignment.center,
width: 200,
height: 200,
color: Colors.red,
child: Text("Front"),
),
// back of the card
back: Container(
alignment: Alignment.center,
width: 200,
height: 200,
color: Colors.teal,
child: Text("Back"),
),
),
],
),
),
),
);
}
}