Skip to content

Commit

Permalink
Added flower model to models
Browse files Browse the repository at this point in the history
  • Loading branch information
Maheen-Ilyas committed May 22, 2024
1 parent 4b204c8 commit f35b380
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 24 deletions.
13 changes: 13 additions & 0 deletions lib/models/flower_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';

class Flower {
final String name;
final String resource;
final Color background;

Flower({
required this.name,
required this.resource,
required this.background,
});
}
69 changes: 45 additions & 24 deletions lib/pages/modules/flowers.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_tts/flutter_tts.dart';
import 'package:learn/models/flower_model.dart';
import 'package:learn/utils/assets_path.dart';


class Flower{
final String name;
final String resource;
final Color background;

Flower({required this.name,required this.resource,required this.background});
}


class FlowerPage extends StatefulWidget {
const FlowerPage({super.key});

Expand All @@ -21,26 +12,56 @@ class FlowerPage extends StatefulWidget {
}

class _FlowerPageState extends State<FlowerPage> {

final List<Flower> flowers = [
Flower(name: "Rose", resource: AssetsPath.getFlowerImage(Flowers.rose), background: Colors.redAccent),
Flower(name: "Sunflower", resource: AssetsPath.getFlowerImage(Flowers.sunflower), background: Colors.yellowAccent),
Flower(name: "Lily", resource: AssetsPath.getFlowerImage(Flowers.lily), background: Colors.greenAccent),
Flower(name: "Marigold", resource: AssetsPath.getFlowerImage(Flowers.marigold), background: Colors.yellow),
Flower(name: "Carnation", resource: AssetsPath.getFlowerImage(Flowers.carnation), background: Colors.redAccent),
Flower(name: "Daffodil", resource: AssetsPath.getFlowerImage(Flowers.daffodil), background: Colors.purpleAccent),
Flower(name: "Daisy", resource: AssetsPath.getFlowerImage(Flowers.daisy), background: Colors.green),
Flower(name: "Poppy", resource: AssetsPath.getFlowerImage(Flowers.poppy), background: Colors.redAccent),
Flower(name: "Tulip", resource: AssetsPath.getFlowerImage(Flowers.tulip), background: Colors.pink),
Flower(name: "Lavender", resource: AssetsPath.getFlowerImage(Flowers.lavender), background: Colors.purple),
Flower(name: "Hibiscus", resource: AssetsPath.getFlowerImage(Flowers.hibiscus), background: Colors.red),

Flower(
name: "Rose",
resource: AssetsPath.getFlowerImage(Flowers.rose),
background: Colors.redAccent),
Flower(
name: "Sunflower",
resource: AssetsPath.getFlowerImage(Flowers.sunflower),
background: Colors.yellowAccent),
Flower(
name: "Lily",
resource: AssetsPath.getFlowerImage(Flowers.lily),
background: Colors.greenAccent),
Flower(
name: "Marigold",
resource: AssetsPath.getFlowerImage(Flowers.marigold),
background: Colors.yellow),
Flower(
name: "Carnation",
resource: AssetsPath.getFlowerImage(Flowers.carnation),
background: Colors.redAccent),
Flower(
name: "Daffodil",
resource: AssetsPath.getFlowerImage(Flowers.daffodil),
background: Colors.purpleAccent),
Flower(
name: "Daisy",
resource: AssetsPath.getFlowerImage(Flowers.daisy),
background: Colors.green),
Flower(
name: "Poppy",
resource: AssetsPath.getFlowerImage(Flowers.poppy),
background: Colors.redAccent),
Flower(
name: "Tulip",
resource: AssetsPath.getFlowerImage(Flowers.tulip),
background: Colors.pink),
Flower(
name: "Lavender",
resource: AssetsPath.getFlowerImage(Flowers.lavender),
background: Colors.purple),
Flower(
name: "Hibiscus",
resource: AssetsPath.getFlowerImage(Flowers.hibiscus),
background: Colors.red),
];

final FlutterTts flutterTts = FlutterTts();
int currentIndex = 0;


void _navigateToNextFlower() {
setState(() {
currentIndex = (currentIndex + 1) % flowers.length;
Expand Down

0 comments on commit f35b380

Please sign in to comment.