multiple ListTile on tap not working is there an alternative

16 Views Asked by At

I want to add 12 months in the form of a list and I want to list the questions of each month Question 1, Question 2...Question 20 . What I want to do is as in the picture, the codes do not work in any way as you can see, I am constantly getting an error I have been stuck here for 5 days, is there any alternative? can you help me? i want to do

import 'package:flutter/material.dart';
import 'soruList/turkSoruList.dart';
import 'soruList/arabSoruList.dart';

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



class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'E-Sınav Çıkmış Sorular' ,
      home: Iskele(),
    );
  }
}

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

  @override
  State<Iskele> createState() => _IskeleState();
}

class _IskeleState extends State<Iskele> {

  String appBarTextTurk = 'E-Sınav Çıkmış Sorular ';
  String appBarTextArab = 'أسئلة الامتحان الإلكتروني';


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
        debugShowCheckedModeBanner: false,
        home: Scaffold(
            appBar: AppBar(
              title:  Text(appBarTextTurk+appBarTextArab),
            ),
            body: const AnaEkran()
        )
    );
  }
}



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

  @override
  State<AnaEkran> createState() => _AnaEkranState();
}

class _AnaEkranState extends State<AnaEkran> {



  @override
  Widget build(BuildContext context) {
    return Container(
        child:Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Image.asset('assets/images/wallpaper.png'),
              const Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                  Text('Dil Seçiniz'),
                  Text('اختار اللغة'),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                  ElevatedButton(
                    child: Text('Türkçe'),
                    onPressed:(){Navigator.push(context,
                        MaterialPageRoute(builder: (context)=> turkSoru()));},
                  ),
                  ElevatedButton(
                    child: Text('عربي'),
                    onPressed:(){Navigator.push(context,
                        MaterialPageRoute(builder: (context)=> arabSoru()));},
                  ),
                ],
              ),
              Image.asset('assets/images/wallpaperArab.png'),
            ],
          ),
        )
    );
  }
}


turkSoruList

import 'package:flutter/material.dart';
import 'package:newroce/soruList/soruTurk/1Ocak/ocakSoruList.dart';
import '../models/aylar.dart';

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

class turkSoru extends StatelessWidget {
  turkSoru({super.key});

  List aylar = [
    Aylar.withId(1, 'Ocak'),
    Aylar.withId(2, 'Şubat'),
    Aylar.withId(3, 'Mart'),
    Aylar.withId(4, 'Nisan'),
    Aylar.withId(5, 'Mayıs'),
    Aylar.withId(6, 'Haziran'),
    Aylar.withId(7, 'Temmuz'),
    Aylar.withId(8, 'Ağustos'),
    Aylar.withId(9, 'Eylül'),
    Aylar.withId(10, 'Ekim'),
    Aylar.withId(11, 'Kasım'),
    Aylar.withId(12, 'Aralık'),
  ];


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
            appBar: AppBar(
              leading: BackButton(
                onPressed: () => Navigator.of(context).pop(),
              ),
              title: Text('E-Sınav Çıkmış Sorular'),
            ),
            body: buildAy()));
  }

  Widget buildAy() {
    return ListView(
      padding: EdgeInsets.all(8),
      children: <Widget>[
        ListTile(
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ocakSoruList(),
                ),
              );
            },
    ),
      ]
    );
  }
}

Ocak Sorular

import 'package:flutter/material.dart';
import 'package:newroce/models/aylar.dart';
import 'package:newroce/soruList/soruTurk/6Haziran/haziran.dart';

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

class ocakSoruList extends StatelessWidget {
  ocakSoruList({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
            appBar: AppBar(
              leading: BackButton(
                onPressed: () => Navigator.of(context).pop(),
              ),
              title: Text('E-Sınav Çıkmış Sorular'),
            ),
            body: ocakList()));
  }
}



List sorularOcak = [
  Aylar.withId(1, 'Soru'),
  Aylar.withId(2, 'Soru'),
  Aylar.withId(3, 'Soru'),
  Aylar.withId(4, 'Soru'),
  Aylar.withId(5, 'Soru'),
  Aylar.withId(6, 'Soru'),
  Aylar.withId(7, 'Soru'),
  Aylar.withId(8, 'Soru'),
  Aylar.withId(9, 'Soru'),
  Aylar.withId(10, 'Soru'),
  Aylar.withId(11, 'Soru'),
  Aylar.withId(12, 'Soru'),
];

Widget ocakList() {
  return Center(
      child: ListView(children: [
    ListTile(
        onTap: () {
          haziranSoru();
        },
        title: Text('Soru 1'),
        subtitle: Text('Süre 35 Dakikadır.Başarılar.')),
    ListTile(
        onTap: () {
          haziranSoru();
        },
        title: Text('Soru 1'),
        subtitle: Text('Süre 35 Dakikadır.Başarılar.')),
    ListTile(
        onTap: () {
          haziranSoru();
        },
        title: Text('Soru 1'),
        subtitle: Text('Süre 35 Dakikadır.Başarılar.')),
    ListTile(
        onTap: () {
          haziranSoru();
        },
        title: Text('Soru 1'),
        subtitle: Text('Süre 35 Dakikadır.Başarılar.')),
  ]));
}

0

There are 0 best solutions below