Skip to content

Instantly share code, notes, and snippets.

@dpossas
Last active July 21, 2022 20:40
Show Gist options
  • Save dpossas/e95056a010d6b00a70d9d96571784ab5 to your computer and use it in GitHub Desktop.
Save dpossas/e95056a010d6b00a70d9d96571784ab5 to your computer and use it in GitHub Desktop.
Teclado
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Container(
height: 176,
color: Colors.white,
child: Row(
children: [
Expanded(
flex: 3,
child: Column(
children: [
oneToNineButtons(),
Row(
children: [
_button('<-', 1, bgColor: Colors.orange),
_button('0', 2),
],
),
],
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
_button('Cancelar', 2, bgColor: Colors.red, width: 80),
_button('Ok', 2, bgColor: Colors.grey, width: 80),
],
),
],
),
),
),
);
}
Widget oneToNineButtons() {
return Column(
children: [
Row(
children: [
_button('1', 1),
_button('2', 1),
_button('3', 1),
],
),
Row(
children: [
_button('4', 1),
_button('5', 1),
_button('6', 1),
],
),
Row(
children: [
_button('7', 1),
_button('8', 1),
_button('9', 1),
],
),
],
);
}
Widget _button(
String label,
int flex, {
Color bgColor = Colors.white,
double? width,
VoidCallback? onPressed,
}) {
return Expanded(
flex: flex,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 2),
child: OutlinedButton(
onPressed: onPressed,
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.all(0),
minimumSize: Size(width ?? 0, 48),
backgroundColor: bgColor,
side: const BorderSide(color: Colors.grey),
),
child: Text(
label,
style: const TextStyle(
color: Colors.black,
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment