Skip to content

Commit

Permalink
Merge pull request #169 from igopi77/master
Browse files Browse the repository at this point in the history
 Fix App Crash When Navigating Within Explore Tab issue : #167
  • Loading branch information
sapatevaibhav authored Jun 2, 2024
2 parents d4c480a + 92b5f66 commit ee4aa71
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions lib/pages/explore/explore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:learn/pages/explore/quiz.dart';
import 'package:learn/pages/modules/atoz.dart';
import 'package:learn/pages/modules/birds.dart';
import 'package:learn/pages/modules/colours.dart';
import 'package:learn/pages/modules/planets.dart';
import 'package:learn/pages/modules/shapes.dart';
import 'package:learn/utils/constants.dart';
import 'package:learn/utils/route/route_constant.dart';

import '../../utils/const_dimensions.dart';

// Explore Page
class ExplorePage extends StatelessWidget {
class ExplorePage extends StatefulWidget {
const ExplorePage({super.key});

@override
State<ExplorePage> createState() => _ExplorePageState();
}

class _ExplorePageState extends State<ExplorePage> {
@override
Widget build(BuildContext context) {
return SafeArea(
Expand All @@ -33,7 +44,7 @@ class ExplorePage extends StatelessWidget {
[
GestureDetector(
onTap: () {
Navigator.pushNamed(context, '/quiz');
Navigator.push(context, (MaterialPageRoute(builder: (context) => const QuizPage())));
},
child: Container(
margin: const EdgeInsets.all(5.0),
Expand Down Expand Up @@ -105,10 +116,38 @@ class ExplorePage extends StatelessWidget {
delegate: SliverChildBuilderDelegate(
(context, index) {
return GestureDetector(
onTap: () => Navigator.push(
context,
AppConstants.modules[index].route,
),
onTap: () {
try{
switch (index) {
case 0:
Navigator.push(context, (MaterialPageRoute(builder: (context) => const QuizPage())));
break;
case 1:
Navigator.push(context, (MaterialPageRoute(builder: (context) => const AtoZ())));
break;
case 2:
Navigator.push(context, (MaterialPageRoute(builder: (context) => BirdsPage())));
break;
case 3:
Navigator.push(context, (MaterialPageRoute(builder: (context) => const ColoursPage())));
break;
case 4:
Navigator.push(context, (MaterialPageRoute(builder: (context) => BirdsPage())));
break;
case 5:
Navigator.push(context, (MaterialPageRoute(builder: (context) => const ShapesPage())));
break;
case 6:
Navigator.push(context, (MaterialPageRoute(builder: (context) => PlanetsPage())));
break;
default:
break;
}
}
catch (e) {
print(e);
}
},
child: Container(
margin: const EdgeInsets.symmetric(
horizontal: 24, vertical: 12),
Expand Down

0 comments on commit ee4aa71

Please sign in to comment.