diff --git a/example/lib/presentation/menu/app_menu.dart b/example/lib/presentation/menu/app_menu.dart index e854f98a2..2c798116b 100644 --- a/example/lib/presentation/menu/app_menu.dart +++ b/example/lib/presentation/menu/app_menu.dart @@ -1,5 +1,4 @@ import 'package:fl_chart_app/presentation/resources/app_resources.dart'; -import 'package:fl_chart_app/urls.dart'; import 'package:fl_chart_app/util/app_helper.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -11,12 +10,14 @@ class AppMenu extends StatefulWidget { final List menuItems; final int currentSelectedIndex; final Function(int, ChartMenuItem) onItemSelected; + final VoidCallback? onBannerClicked; const AppMenu({ Key? key, required this.menuItems, required this.currentSelectedIndex, required this.onItemSelected, + required this.onBannerClicked, }) : super(key: key); @override @@ -36,12 +37,7 @@ class AppMenuState extends State { aspectRatio: 3, child: Center( child: InkWell( - onTap: () async { - final url = Uri.parse(Urls.flChartUrl); - if (await canLaunchUrl(url)) { - await launchUrl(url); - } - }, + onTap: widget.onBannerClicked, child: const FlChartBanner(), ), ), diff --git a/example/lib/presentation/pages/home_page.dart b/example/lib/presentation/pages/home_page.dart index 35df81d42..2fedf73dc 100644 --- a/example/lib/presentation/pages/home_page.dart +++ b/example/lib/presentation/pages/home_page.dart @@ -1,9 +1,12 @@ import 'package:dartx/dartx.dart'; import 'package:fl_chart_app/presentation/menu/app_menu.dart'; import 'package:fl_chart_app/presentation/resources/app_resources.dart'; +import 'package:fl_chart_app/urls.dart'; import 'package:fl_chart_app/util/app_helper.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'chart_samples_page.dart'; @@ -50,6 +53,19 @@ class HomePage extends StatelessWidget { Navigator.of(context).pop(); } }, + onBannerClicked: kIsWeb || needsDrawer ? () async { + if (kIsWeb) { + final url = Uri.parse(Urls.flChartUrl); + if (await canLaunchUrl(url)) { + await launchUrl(url); + } + return; + } + if (needsDrawer) { + Navigator.of(context).pop(); + return; + } + } : null, ); final samplesSectionWidget = ChartSamplesPage(chartType: showingChartType);