Created
July 13, 2021 05:57
-
-
Save Aldo111/169845847ccd20bcda101a933adad1b4 to your computer and use it in GitHub Desktop.
Flutter E-Store Tutorial Part 3 Files
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
// constants/app_style.dart | |
import 'package:flutter/material.dart'; | |
abstract class AppStyle { | |
static const primaryColor = Color(0xFFFDFDFD); | |
static const secondaryColor = Color(0xFF252525); | |
static const backgroundGrey = Color(0xFF383838); | |
static const captionColor = Color(0xFFbababa); | |
static const double iconSize = 36.0; | |
static const double padding = 24.0; | |
} |
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
// screens/home_screen.dart | |
import 'package:curvy_background/constants/app_style.dart'; | |
import 'package:curvy_background/models/product.dart'; | |
import 'package:curvy_background/widgets/headphone_banner.dart'; | |
import 'package:flutter/material.dart'; | |
class HomeScreen extends StatelessWidget { | |
const HomeScreen({ | |
Key? key, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
children: [ | |
Expanded( | |
child: Stack( | |
children: [ | |
Container(color: AppStyle.secondaryColor), | |
Container( | |
child: Padding( | |
padding: const EdgeInsets.symmetric( | |
horizontal: AppStyle.padding), | |
child: Column(children: [ | |
HeadphoneBanner(Product( | |
'Headphone X1', | |
'assets/images/headphones.png', | |
100, | |
)), | |
]), | |
), | |
decoration: BoxDecoration( | |
color: AppStyle.primaryColor, | |
borderRadius: | |
BorderRadius.only(bottomLeft: Radius.circular(88)))), | |
], | |
), | |
), | |
Container( | |
height: 200, | |
child: Stack( | |
children: [ | |
Container(color: AppStyle.primaryColor), | |
Container( | |
decoration: BoxDecoration( | |
color: AppStyle.secondaryColor, | |
borderRadius: | |
BorderRadius.only(topRight: Radius.circular(88)))), | |
], | |
), | |
), | |
], | |
); | |
} | |
} |
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:curvy_background/constants/app_style.dart'; | |
import 'package:curvy_background/screens/home_screen.dart'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
const imageUrl = | |
'https://upload.wikimedia.org/wikipedia/commons/a/a0/Arh-avatar.jpg'; | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
appBarTheme: AppBarTheme( | |
backgroundColor: AppStyle.primaryColor, | |
iconTheme: IconThemeData( | |
color: AppStyle.secondaryColor, | |
size: AppStyle.iconSize, | |
))), | |
home: Scaffold( | |
appBar: AppBar( | |
leading: Padding( | |
padding: const EdgeInsets.only(left: 16.0), | |
child: Icon( | |
Icons.grid_view, | |
), | |
), | |
elevation: 0, | |
actions: [ | |
IconButton( | |
iconSize: AppStyle.iconSize, | |
onPressed: () {}, | |
icon: Icon(Icons.search), | |
), | |
Stack( | |
children: [ | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: ClipRRect( | |
child: Image.network( | |
imageUrl, | |
width: 36, | |
), | |
borderRadius: BorderRadius.circular(8), | |
), | |
), | |
Positioned( | |
top: 3, | |
right: 3, | |
child: Container( | |
width: 12, | |
height: 12, | |
decoration: BoxDecoration( | |
color: Colors.red, | |
borderRadius: BorderRadius.circular(12))), | |
), | |
], | |
), | |
SizedBox(width: 16), | |
], | |
), | |
body: HomeScreen())); | |
} | |
} |
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
// models/product.dart | |
class Product { | |
final String name; | |
final String imagePath; | |
final int price; | |
Product(this.name, this.imagePath, this.price); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment