Istalgan kvadrat funksiya grafigini chizuvchi dastur yaratish


Download 20 Kb.
Sana19.06.2023
Hajmi20 Kb.
#1612088
Bog'liq
2.Mar-mustaqil ish


Istalgan kvadrat funksiya grafigini chizuvchi dastur yaratish.
Flutter-da kvadrat funksiyaning grafikini chizuvchi dastur yaratish uchun quyidagi kodni ishlatishingiz mumkin:

1. Flutter proyektini yaratish:


flutter create kvadrat_funksiya

2. `lib/main.dart` faylini oching va mavjud kodni o’chirib tashlab.

3. Quyidagi kodni `lib/main.dart` fayliga qo'shing:

```dart
import 'package:flutter/material.dart';


import 'package:charts_flutter/flutter.dart' as charts;

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Kvadrat Funksiya',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}

class MyHomePage extends StatelessWidget {


final List seriesList = [
charts.Series(
id: 'Kvadrat Funksiya',
domainFn: (num value, _) => value,
measureFn: (num value, _) => value * value,
data: List.generate(100, (index) => index.toDouble()),
),
];

@override


Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Kvadrat Funksiya'),
),
body: Center(
child: Container(
height: 300,
padding: EdgeInsets.all(16.0),
child: charts.LineChart(seriesList),
),
),
);
}
}
```

4. `pubspec.yaml` faylida `charts_flutter` paketini qo'shing:

```yaml
dependencies:
flutter:
sdk: flutter
charts_flutter: ^0.11.0
```

5. Proyektni qurilgan qo'llab-quvvatlash vositasida ishga tushiring:



```bash
flutter run
```

Bu dastur kvadrat funksiyaning grafikini chizadi va 0 dan 99 gacha bo'lgan x qiymatlari uchun kvadrat qiymatlarni ko'rsatadi. Grafikni chizish uchun `charts_flutter` paketidan foydalanilgan.
Download 20 Kb.

Do'stlaringiz bilan baham:




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