Skip to content

Instantly share code, notes, and snippets.

@siumhossain
Created February 14, 2021 08:54
Show Gist options
  • Save siumhossain/81eb4e2cb39d741997e8cd6bf6dd32ed to your computer and use it in GitHub Desktop.
Save siumhossain/81eb4e2cb39d741997e8cd6bf6dd32ed to your computer and use it in GitHub Desktop.
set counter in flutter
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: NinjaCard(),
));
class NinjaCard extends StatefulWidget {
@override
_NinjaCardState createState() => _NinjaCardState();
}
class _NinjaCardState extends State<NinjaCard> {
int ninjaLevel = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[900],
appBar: AppBar(
title: Text('Ninja ID Card'),
centerTitle: true,
backgroundColor: Colors.grey[850],
elevation: 0.0,
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
ninjaLevel += 1;
});
},
backgroundColor: Colors.grey[800],
child: Icon(Icons.add),
),
body: Padding(
padding: const EdgeInsets.fromLTRB(30.0, 40.0, 30.0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Center(
child: CircleAvatar(
radius: 40.0,
backgroundImage: AssetImage('assets/thumb.jpg'),
),
),
Divider(
color: Colors.grey[800],
height: 60.0,
),
Text(
'NAME',
style: TextStyle(
color: Colors.grey,
letterSpacing: 2.0,
),
),
SizedBox(height: 10.0),
Text(
'Chun-Li',
style: TextStyle(
color: Colors.amberAccent[200],
fontWeight: FontWeight.bold,
fontSize: 28.0,
letterSpacing: 2.0,
),
),
SizedBox(height: 30.0),
Text(
'HOMETOWN',
style: TextStyle(
color: Colors.grey,
letterSpacing: 2.0,
),
),
SizedBox(height: 10.0),
Text(
'Beijing, China',
style: TextStyle(
color: Colors.amberAccent[200],
fontWeight: FontWeight.bold,
fontSize: 28.0,
letterSpacing: 2.0,
),
),
SizedBox(height: 30.0),
Text(
'CURRENT NINJA LEVEL',
style: TextStyle(
color: Colors.grey,
letterSpacing: 2.0,
),
),
SizedBox(height: 10.0),
Text(
'$ninjaLevel',
style: TextStyle(
color: Colors.amberAccent[200],
fontWeight: FontWeight.bold,
fontSize: 28.0,
letterSpacing: 2.0,
),
),
SizedBox(height: 30.0),
Row(
children: <Widget>[
Icon(
Icons.email,
color: Colors.grey[400],
),
SizedBox(width: 10.0),
Text(
'[email protected]',
style: TextStyle(
color: Colors.grey[400],
fontSize: 18.0,
letterSpacing: 1.0,
),
)
],
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment