Advertisement
rajath_pai

ninja16 Stateful Widgets

Jul 30th, 2021
1,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.31 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MaterialApp(
  4.       home: Home(),
  5.     ));
  6.  
  7.  
  8. class Home extends StatefulWidget{
  9.   @override
  10.   _HomeCardState createState() => _HomeCardState();
  11. }
  12.  
  13. class _HomeCardState extends State<Home> {
  14.  
  15.   int count = 0;
  16.  
  17.   @override
  18.   Widget build(BuildContext context) {
  19.     return Scaffold(
  20.       backgroundColor: Colors.grey[900],
  21.       appBar: AppBar(
  22.         title: Text(
  23.           'Pi ID Card',
  24.         ),
  25.         centerTitle: true,
  26.         backgroundColor: Colors.grey[850],
  27.         elevation: 0.0, // to remove shadow of the appBar
  28.       ),
  29.       floatingActionButton : FloatingActionButton(
  30.         onPressed : (){
  31.           setState((){ // used to change the state of any widget
  32.              count++;
  33.           },);
  34.         },
  35.         child : Icon(
  36.           Icons.add,
  37. //           color : Colors.amberAccent[200],
  38.         ),
  39.         backgroundColor : Colors.grey[800],
  40.       ),
  41.       body: Padding(
  42.         padding: EdgeInsets.fromLTRB(30.0, 40.0, 30.0, 0.0),
  43.         child: Column(
  44.           crossAxisAlignment: CrossAxisAlignment.start,
  45.           children: <Widget>[
  46.             Center(
  47.               child : CircleAvatar(
  48.                 backgroundImage : NetworkImage('https://image.flaticon.com/icons/png/512/2726/2726000.png'),
  49.                 radius : 40.0,
  50.                 backgroundColor : Colors.grey[900],
  51.               ),
  52.             ),
  53.             Divider(
  54.               height : 60.0,
  55.               color : Colors.grey[800],
  56.             ),
  57.             Text(
  58.               'NAME',
  59.               style: TextStyle(
  60.                 color: Colors.grey,
  61.                 letterSpacing: 2.0,
  62.               ),
  63.             ),
  64.             //sizedbox => simple alternative for padding between 2 elements(words)
  65.             SizedBox(height: 10.0),
  66.             Text(
  67.               'Rajath Pai',
  68.               style: TextStyle(
  69.                 color: Colors.amberAccent[200],
  70.                 letterSpacing: 2.0,
  71.                 fontSize: 20.0,
  72.                 fontWeight: FontWeight.bold,
  73.               ),
  74.             ),
  75.             SizedBox(height: 30.0),
  76.             Text(
  77.               'Current Level',
  78.               style: TextStyle(
  79.                 color: Colors.grey,
  80.                 letterSpacing: 2.0,
  81.               ),
  82.             ),
  83.             //sizedbox => simple alternative for padding between 2 elements(words)
  84.             SizedBox(height: 10.0),
  85.             Text(
  86.               '$count',
  87.               style: TextStyle(
  88.                 color: Colors.amberAccent[200],
  89.                 letterSpacing: 2.0,
  90.                 fontSize: 20.0,
  91.                 fontWeight: FontWeight.bold,
  92.               ),
  93.             ),
  94.             SizedBox(height: 30.0),
  95.             Row(
  96.               children : <Widget>[
  97.                 Icon(
  98.                   Icons.email,
  99.                   color : Colors.grey[400],
  100.                 ),
  101.                 SizedBox(width : 10.0),
  102.                 Text(
  103.                   'pai@gmail.com',
  104.                   style : TextStyle(
  105.                     color : Colors.grey[400],
  106.                     fontSize : 18.0,
  107.                     letterSpacing : 1.0,
  108.                   ),
  109.                 ),
  110.               ],
  111.             ),
  112.           ],
  113.         ),
  114.       ),
  115.     );
  116.   }
  117. }
  118.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement