Skip to content

Instantly share code, notes, and snippets.

@Nash0x7E2
Created October 22, 2018 23:54
Show Gist options
  • Save Nash0x7E2/52f415f9946c69ea645fea4b98f3a7cb to your computer and use it in GitHub Desktop.
Save Nash0x7E2/52f415f9946c69ea645fea4b98f3a7cb to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(home: MyApp()));
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.amberAccent,
body: SafeArea(
child: Center(
child: PersonCard(),
),
),
);
}
}
class PersonCard extends StatelessWidget {
int counter = 0;
@override
Widget build(BuildContext contex) {
return Card(
child: SizedBox(
width: 300.0,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(18.0),
child: Text(
"Luke Skywalker",
style:
TextStyle(fontSize: 16.0, fontWeight: FontWeight.w700),
),
),
Padding(
padding: const EdgeInsets.all(18.0),
child: Text(
"Age: 23",
style:
TextStyle(fontSize: 16.0, fontWeight: FontWeight.w700),
),
),
],
),
SizedBox(height: 12.0),
Center(
child: Container(
height: 130.0,
width: 130.0,
child: Image.asset("assets/skywalker.png"),
),
),
SizedBox(height: 12.0),
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(
icon: Icon(Icons.skip_previous),
onPressed: () {
setState(() {
counter--;
});
},
),
Text(
"$counter",
style: Theme.of(context).textTheme.body2,
),
IconButton(
icon: Icon(Icons.skip_next),
onPressed: () {
setState(() {
counter++;
});
},
),
],
);
},
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment