Skip to content

Instantly share code, notes, and snippets.

@cerberodev
Created October 28, 2021 02:45
Show Gist options
  • Save cerberodev/f41249029d454629e34bdd2b75324a5b to your computer and use it in GitHub Desktop.
Save cerberodev/f41249029d454629e34bdd2b75324a5b to your computer and use it in GitHub Desktop.
Sesión2
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.green,
floatingActionButtonTheme: const FloatingActionButtonThemeData(
backgroundColor: Colors.red,
),
),
darkTheme: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.green,
floatingActionButtonTheme: const FloatingActionButtonThemeData(
backgroundColor: Colors.red,
),
appBarTheme: const AppBarTheme(
color: Colors.green,
),
),
home: const MyHomePage(title: ' Demo 2two platforms Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
void _decrementCounter() {
setState(() {
_counter--;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: [
IconButton(
icon: const Icon(Icons.add),
onPressed: _incrementCounter,
),
IconButton(
icon: const Icon(Icons.remove),
onPressed: _decrementCounter,
),
],
),
drawer: Drawer(
child: ListView(
children: [
DrawerHeader(
child: Column(
children: const [
Text('Drawer Header'),
Icon(Icons.flutter_dash, size: 100, color: Colors.red),
],
),
decoration: const BoxDecoration(
color: Colors.green,
),
),
ListTile(
title: const Text('Item 234234'),
onTap: () {
Navigator.pop(context);
},
leading: const Icon(Icons.person),
subtitle: const Text(
'Culpa ipsum ullamco laborum tempor tempor. Tempor ad sunt consectetur aliquip culpa labore occaecat. Minim do est commodo nisi esse voluptate fugiat fugiat est eiusmod nisi adipisicing. Nisi proident enim veniam officia amet eu adipisicing ex nisi. Amet eu dolor exercitation id exercitation adipisicing laborum ullamco reprehenderit anim ex. Irure exercitation elit eiusmod eu amet deserunt amet occaecat do aute incididunt dolor.',
overflow: TextOverflow.ellipsis,
maxLines: 3,
),
trailing: const Icon(Icons.more_vert),
contentPadding: const EdgeInsets.symmetric(horizontal: 10),
minLeadingWidth: 10,
),
ListTile(
title: const Text('Item 2'),
onTap: () {
Navigator.pop(context);
},
),
],
),
),
body: Center(
child: Column(
children: [
Expanded(
flex: 2,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
Expanded(
flex: 4,
child: Container(
alignment: Alignment.center,
color: Colors.red,
width: double.infinity,
child: Column(
children: [
Card(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: () {
print('Tappet: Call');
},
child: Column(
mainAxisSize: MainAxisSize.min,
children: const [
Icon(Icons.phone),
Text('Call'),
],
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: const [
Icon(Icons.north_east_rounded),
Text('Route'),
],
),
IconButton(
onPressed: () {
print('Tappet: Share');
},
icon: Column(
mainAxisSize: MainAxisSize.min,
children: const [
Icon(Icons.share),
Text('Share'),
],
),
padding: const EdgeInsets.all(0),
)
],
),
),
Container(
margin: const EdgeInsets.all(8),
color: Colors.yellow,
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ListTile(
leading: const Icon(Icons.restaurant_menu),
title: const Text('1625 Main Street'),
onTap: () {
print('Tappet: Address');
},
subtitle: const Text('My City, CA 99984'),
),
const Divider(
color: Colors.black,
height: 25,
),
ListTile(
leading: const Icon(Icons.contact_phone),
title: const Text('(408) 555-1212'),
onTap: () {
print('Tappet: Address');
},
),
ListTile(
leading: const Icon(Icons.contact_mail),
title: const Text('costa@example.com'),
onTap: () {
print('Tappet: Address');
},
),
],
),
),
],
),
),
),
],
),
),
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
const SizedBox(width: 10),
FloatingActionButton(
onPressed: _decrementCounter,
tooltip: 'Decrement',
child: const Icon(Icons.remove),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment