Skip to content

Instantly share code, notes, and snippets.

@usimsek
Created August 17, 2020 23:10
Show Gist options
  • Save usimsek/a02f20d3c8bb71e9dbfbf04e9e1282d1 to your computer and use it in GitHub Desktop.
Save usimsek/a02f20d3c8bb71e9dbfbf04e9e1282d1 to your computer and use it in GitHub Desktop.
Genel Flutter widget - Common flutter widget
import 'package:flutter/material.dart';
final 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: Center(
child: ListDemo(),
),
),
);
}
}
class ColumnDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blueAccent,
body: SafeArea(
child: Center(
child: Card(
elevation: 12,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
FlutterLogo(size: 48),
SizedBox(
height: 16,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Title of the Card',
style: Theme.of(context).textTheme.headline5,
),
Text('Some description',
style: Theme.of(context).textTheme.headline6),
],
),
],
),
),
),
),
),
);
}
}
class RowDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blueAccent,
body: SafeArea(
child: Center(
child: Card(
margin: EdgeInsets.all(16),
elevation: 12,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
color: Colors.white,
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 36),
child: Row(
children: <Widget>[
FlutterLogo(size: 48),
SizedBox(
width: 16,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'Title of the Card',
style: Theme.of(context).textTheme.headline5,
),
Text('Some description',
style: Theme.of(context).textTheme.headline6),
],
),
),
Icon(
Icons.navigate_next,
size: 36,
),
],
),
),
),
),
),
);
}
}
class StackDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blueAccent,
body: SafeArea(
child: Center(
child: Container(
margin: EdgeInsets.all(16),
child: Stack(
children: <Widget>[
Opacity(
opacity: 1,
child: Card(
elevation: 12,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
color: Colors.white,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 24.0, vertical: 36),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FlutterLogo(size: 48),
SizedBox(
width: 16,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'Title of the Card',
style: Theme.of(context).textTheme.headline5,
),
Text('Some description',
style:
Theme.of(context).textTheme.headline6),
],
),
),
Icon(
Icons.navigate_next,
size: 36,
)
],
),
),
),
),
Positioned(
left: 8,
top: 8,
child: Icon(Icons.star, color: Colors.amber, size: 36),
),
// Positioned.fill(
// child: Icon(
// Icons.block,
// size: 72,
// )),
],
),
),
),
),
);
}
}
class ContainerDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
child: Center(
child: Container(
margin: EdgeInsets.all(16),
child: Stack(
children: <Widget>[
Card(
elevation: 12,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
color: Colors.white,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 24.0, vertical: 36),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFF213B6C), Color(0xFF0059A5)]),
boxShadow: [
BoxShadow(
color: Colors.pink,
blurRadius: 12,
offset: Offset(3, 12)),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FlutterLogo(size: 48),
SizedBox(
width: 16,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'Title of the Card',
style: Theme.of(context)
.textTheme
.headline5
.copyWith(color: Colors.white),
),
Text('Some description',
style: Theme.of(context)
.textTheme
.headline6
.copyWith(color: Colors.white)),
],
),
),
Icon(
Icons.navigate_next,
size: 36,
color: Colors.white,
)
],
),
),
),
Positioned(
left: 8,
top: 8,
child: Icon(
Icons.star,
size: 32,
color: Colors.deepOrangeAccent,
),
),
],
),
),
),
),
);
}
}
class ListDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ListView.builder(
itemCount: 5,
itemBuilder: (context, index) {
return Container(
margin: EdgeInsets.all(16),
child: Stack(
children: <Widget>[
Card(
elevation: 12,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
color: Colors.white,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 24.0, vertical: 36),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24),
gradient: LinearGradient(
colors: [Color(0xFF213B6C), Color(0xFF0059A5)]),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FlutterLogo(size: 48),
SizedBox(
width: 16,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'Title of the Card',
style: Theme.of(context)
.textTheme
.headline5
.copyWith(color: Colors.white),
),
Text('Some description',
style: Theme.of(context)
.textTheme
.headline6
.copyWith(color: Colors.white)),
],
),
),
Icon(
Icons.navigate_next,
size: 36,
color: Colors.white,
)
],
),
),
),
Positioned(
left: 8,
top: 8,
child: Icon(
Icons.star,
size: 32,
color: Colors.deepOrangeAccent,
),
),
],
),
);
}),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment