Topshiriq №2 Mavzu: Sturukturali dasturlash



Download 0,55 Mb.
bet4/4
Sana21.01.2022
Hajmi0,55 Mb.
#397434
1   2   3   4
Bog'liq
Mamurov G\'olibjon 1

body: Body(),

);

}

AppBar buildAppBar() {

return AppBar(

backgroundColor: Colors.white,

elevation: 0,

leading: IconButton(

icon: SvgPicture.asset("assets/icons/back.svg"),

onPressed: () {},

),

actions: [

IconButton(

icon: SvgPicture.asset(

"assets/icons/search.svg",

// By default our icon color is white

color: kTextColor,

),

onPressed: () {},

),

IconButton(

icon: SvgPicture.asset(

"assets/icons/cart.svg",

// By default our icon color is white

color: kTextColor,

),

onPressed: () {},

),

SizedBox(width: kDefaultPaddin / 2)

],

);

}}

2-sahifa:

import 'package:flutter/material.dart';

import 'package:shop_app/constants.dart';

import 'package:shop_app/models/Product.dart';

import 'package:shop_app/screens/details/details_screen.dart';

import 'categorries.dart';

import 'item_card.dart';

class Body extends StatelessWidget {

@override

Widget build(BuildContext context) {

return Column(

crossAxisAlignment: CrossAxisAlignment.start,

children: [

Padding(


padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin),

child: Text(

"Women",

style: Theme.of(context)

.textTheme

.headline5

.copyWith(fontWeight: FontWeight.bold),

),

),



Categories(),

Expanded(

child: Padding(

padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin),

child: GridView.builder(

itemCount: products.length,

gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(

crossAxisCount: 2,

mainAxisSpacing: kDefaultPaddin,

crossAxisSpacing: kDefaultPaddin,

childAspectRatio: 0.75,

),

itemBuilder: (context, index) => ItemCard(



product: products[index],

press: () => Navigator.push(

context,

MaterialPageRoute(

builder: (context) => DetailsScreen(

product: products[index],

),

)),


)),

),

),



],

);

}



}

3-sahifa:

import 'package:flutter/material.dart';

import '../../../constants.dart';

// We need satefull widget for our categories

class Categories extends StatefulWidget {

@override

_CategoriesState createState() => _CategoriesState();

}

class _CategoriesState extends State {



List categories = ["Hand bag", "Jewellery", "Footwear", "Dresses"];

// By default our first item will be selected

int selectedIndex = 0;

@override

Widget build(BuildContext context) {

return Padding(

padding: const EdgeInsets.symmetric(vertical: kDefaultPaddin),

child: SizedBox(

height: 25,

child: ListView.builder(

scrollDirection: Axis.horizontal,

itemCount: categories.length,

itemBuilder: (context, index) => buildCategory(index),

),

),



);

}

Widget buildCategory(int index) {



return GestureDetector(

onTap: () {

setState(() {

selectedIndex = index;

});

},

child: Padding(



padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin),

child: Column(

crossAxisAlignment: CrossAxisAlignment.start,

children: [

Text(

categories[index],



style: TextStyle(

fontWeight: FontWeight.bold,

color: selectedIndex == index ? kTextColor : kTextLightColor,

),

),



Container(

margin: EdgeInsets.only(top: kDefaultPaddin / 4), //top padding 5

height: 2,

width: 30,

color: selectedIndex == index ? Colors.black : Colors.transparent,

)

],



), ),);}}

Dastur ko’rinishi:






Download 0,55 Mb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish