Flutter ramka uchun qo'llanma 1-bob. Flutterga kirish Flutter nima. O'rnatish


Download 1.13 Mb.
bet18/27
Sana03.12.2023
Hajmi1.13 Mb.
#1798657
1   ...   14   15   16   17   18   19   20   21   ...   27
Bog'liq
Flutter ramka uchun qo\'llanma 1-bob. Flutterga kirish Flutter ni

Yuqori tugma

ElevatedButton vidjeti tugmani ifodalaydi, uning asosiy vazifasi bosilganda javob berish va ba'zi harakatlarni bajarishdir.


Ushbu vidjetda ikkita konstruktor mavjud. Birinchi konstruktor:




1
2

ElevatedButton({Key key, @required VoidCallback onPressed, VoidCallback onLongPress, ButtonStyle style,
FocusNode focusNode, bool autofocus: false, Clip clipBehavior: Clip.none, @required Widget child})

Keling, ba'zi parametrlarni ko'rib chiqaylik:


kalit: buyumning kaliti


onPressed: bosilganda chaqiriladigan harakatni tavsiflaydi


onLongPress: uzoq bosilganda chaqiriladigan harakatni tavsiflaydi


uslub: tugma uslubi


focusNode: klaviatura fokuslarini qabul qilish va klaviatura hodisalarini boshqarish uchun ishlatiladigan ob'ekt


avtofokus: tugma sukut bo'yicha fokusni olish-olmasligini bildiradi


clipBehavior: tugma mazmuni qanday qirqib olinishini belgilaydi


bola: boshqa vidjet sifatida tugma mazmuni (odatda tugmachadagi yorliq)


Ikkinchi konstruktor piktogramma parametridan vidjet ko'rinishidagi belgini qo'shimcha ravishda qo'shish imkonini beradi:




1
2

ElevatedButton.icon({Key key, @required VoidCallback onPressed, VoidCallback onLongPress, ButtonStyle style,
FocusNode focusNode, bool autofocus, Clip clipBehavior, @required Widget icon, @required Widget label})

Eng oddiy ElevatedButtonni yaratish:




1
2
3
4
5
6
7
8
9
10
11
12

import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: Scaffold(
body: ElevatedButton(
child:Text("Click", style: TextStyle(fontSize: 22),)
),
appBar: AppBar(title:Text("METANIT.COM")),
)
));
}


Skrinshotdan ko'rinib turibdiki, tugma sukut bo'yicha faol emas, chunki biz uni bosilganda chaqirish uchun amal o'rnatmaganmiz - ya'ni onPressed parametri.


Bu parametr mohiyatan hech narsa qaytarmaydigan va parametrlarni olmaydigan bo'sh Funktsiyani () ifodalaydi. Masalan, biz hatto bo'sh funksiyadan ham foydalanishimiz mumkin:





1
2
3
4

ElevatedButton(
child: Text("Click", style: TextStyle(fontSize: 22)),
onPressed:(){}
)

Oddiy misol sifatida, tugmani bosish orqali konsolga ma'lum bir qatorni chiqaramiz:




1
2
3
4
5
6
7
8
9
10
11
12

import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: Scaffold(
body: ElevatedButton(
child: Text("Click", style: TextStyle(fontSize: 22)),
onPressed:(){ print("Clicked!!!");}
),
appBar: AppBar(title: Text("METANIT.COM")),)
));
}

Chop etish () funksiyasi tugma bosilganda konsolga ma'lumot chiqaradi:




Yo'nalish vidjeti
Ba'zi konteynerlarga ElevatedButtonni joylashtirishda xatolikka duch kelishimiz mumkin



1

No Directionality widget found.

Bunday holda, siz asosiy konteynerni Yo'nalish vidjetiga o'rashingiz mumkin:





1
2
3
4
5
6
7
8
9
10
11
12
13
14

import 'package:flutter/material.dart';
int count = 0;
void main() {
runApp(Directionality(
textDirection: TextDirection.rtl,
child: Container(
color: Colors.white,
padding: EdgeInsets.only(top:25),
child: ElevatedButton(
child:Text("Click", textDirection: TextDirection.ltr)
)),
));
}

Yoki MaterialApp kabi yoʻnalishni bilvosita qoʻllaydigan boshqa vidjetlardan foydalaning.





Download 1.13 Mb.

Do'stlaringiz bilan baham:
1   ...   14   15   16   17   18   19   20   21   ...   27




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