Last active
March 2, 2023 01:43
-
-
Save cerberodev/cf496af84b5ea19ca1f87873aa30fc2e to your computer and use it in GitHub Desktop.
App Flutter for show 3 ListTile (Cupertino, Material, MyDesign) for Bootcamp of UCamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter/cupertino.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData(brightness: Brightness.light), | |
darkTheme: ThemeData(brightness: Brightness.dark), | |
home: const MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
final String title; | |
const MyHomePage({ | |
Key? key, | |
required this.title, | |
}) : super(key: key); | |
@override | |
State<MyHomePage> createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
final theme = Theme.of(context); | |
final textTheme = theme.textTheme; | |
final colorScheme = theme.colorScheme; | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
mainAxisSize: MainAxisSize.min, | |
children: [ | |
CupertinoListTile( | |
title: Text('Hola Mundo', style: textTheme.titleLarge), | |
leading: const Icon(Icons.apple), | |
trailing: const Icon(Icons.flutter_dash), | |
), | |
const Divider(), | |
ListTile( | |
title: Text('Hola Mundo', style: textTheme.titleLarge), | |
leading: const Icon(Icons.android), | |
trailing: const Icon(Icons.flutter_dash), | |
selectedColor: colorScheme.onPrimary, | |
), | |
const Divider(), | |
const UCampListTile( | |
title: 'List Tile', | |
subtitle: 'Subtitle UCampListTile', | |
leadingIcon: Icons.school, | |
trailingIcon: Icons.flutter_dash, | |
), | |
], | |
), | |
), | |
); | |
} | |
} | |
class UCampListTile extends StatelessWidget { | |
const UCampListTile({ | |
super.key, | |
required this.title, | |
required this.subtitle, | |
required this.leadingIcon, | |
required this.trailingIcon, | |
}); | |
final String title; | |
final String subtitle; | |
final IconData leadingIcon; | |
final IconData trailingIcon; | |
@override | |
Widget build(BuildContext context) { | |
final theme = Theme.of(context); | |
final textTheme = theme.textTheme; | |
return Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 16.0), | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: [ | |
Container( | |
alignment: Alignment.center, | |
child: Icon(leadingIcon), | |
), | |
const SizedBox(width: 16), | |
Expanded( | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text( | |
title, | |
style: textTheme.titleLarge, | |
textAlign: TextAlign.start, | |
), | |
Text( | |
subtitle, | |
style: textTheme.titleMedium, | |
textAlign: TextAlign.start, | |
), | |
], | |
), | |
), | |
Container( | |
alignment: Alignment.center, | |
padding: const EdgeInsets.all(2), | |
child: Icon(trailingIcon), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment