Created
December 2, 2020 13:34
-
-
Save anoochit/d5393b68c6cabfd0f6f04c88b3a06851 to your computer and use it in GitHub Desktop.
card view with clip behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
// This is the theme of your application. | |
// | |
// Try running your application with "flutter run". You'll see the | |
// application has a blue toolbar. Then, without quitting the app, try | |
// changing the primarySwatch below to Colors.green and then invoke | |
// "hot reload" (press "r" in the console where you ran "flutter run", | |
// or simply save your changes to "hot reload" in a Flutter IDE). | |
// Notice that the counter didn't reset back to zero; the application | |
// is not restarted. | |
primarySwatch: Colors.indigo, | |
// This makes the visual density adapt to the platform that you run | |
// the app on. For desktop platforms, the controls will be smaller and | |
// closer together (more dense) than on mobile platforms. | |
visualDensity: VisualDensity.adaptivePlatformDensity, | |
canvasColor: Colors.grey[800], | |
), | |
home: HomePage(), | |
); | |
} | |
} | |
class HomePage extends StatefulWidget { | |
HomePage({Key key}) : super(key: key); | |
@override | |
_HomePageState createState() => _HomePageState(); | |
} | |
class _HomePageState extends State<HomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: Container( | |
child: Card( | |
clipBehavior: Clip.antiAliasWithSaveLayer, | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(15.0), | |
), | |
color: Colors.grey, | |
child: Container( | |
width: 400, | |
height: 400, | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
SizedBox( | |
height: 160, | |
), | |
Icon( | |
Icons.ac_unit, | |
size: 40, | |
), | |
SizedBox( | |
height: 160, | |
), | |
Container( | |
width: 400, | |
height: 40, | |
alignment: Alignment.center, | |
decoration: BoxDecoration(color: Colors.amber), | |
child: Text("Air Con"), | |
) | |
], | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment