Skip to content

Instantly share code, notes, and snippets.

@hansvdam
Created August 12, 2024 15:03
Show Gist options
  • Save hansvdam/857ba2c16d4530868aa0be499e6ab7c7 to your computer and use it in GitHub Desktop.
Save hansvdam/857ba2c16d4530868aa0be499e6ab7c7 to your computer and use it in GitHub Desktop.
Generated code from pixels2flutter.dev
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[800],
appBar: AppBar(
backgroundColor: Colors.grey[800],
leading: Icon(Icons.menu, color: Colors.white),
title: Text(''),
actions: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'12:00',
style: TextStyle(color: Colors.white, fontSize: 16),
),
),
],
),
body: Column(
children: [
Container(
color: Colors.lightGreen,
padding: EdgeInsets.all(16),
child: Center(
child: Text(
'BS-Kaart (9/17)',
style: TextStyle(color: Colors.black, fontSize: 20),
),
),
),
Container(
color: Colors.grey[700],
padding: EdgeInsets.all(16),
child: Center(
child: Text(
'VKM 5G12',
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
),
Expanded(
child: Container(
color: Colors.grey[800],
),
),
Row(
children: [
Expanded(
child: CustomButton(
icon: Icons.error_outline,
text: 'STORING',
isPressed: false,
),
),
Expanded(
child: CustomButton(
icon: Icons.burst_mode,
text: 'INCIDENT',
isPressed: true,
),
),
],
),
CustomButton(
icon: Icons.label,
text: 'AFMELDEN',
isPressed: false,
subText: '5G12',
),
],
),
);
}
}
class CustomButton extends StatelessWidget {
final IconData icon;
final String text;
final bool isPressed;
final String? subText;
CustomButton({
required this.icon,
required this.text,
required this.isPressed,
this.subText,
});
@override
Widget build(BuildContext context) {
return Container(
height: 100,
color: isPressed ? Colors.blue : Colors.grey[300],
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (subText != null)
Container(
padding: EdgeInsets.all(8),
color: Colors.grey[700],
child: Text(
subText!,
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
Icon(icon, color: isPressed ? Colors.white : Colors.black, size: 40),
Text(
text,
style: TextStyle(
color: isPressed ? Colors.white : Colors.black,
fontSize: 20,
),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment