Skip to content

Commit

Permalink
Refactor footer widget to use UrlService
Browse files Browse the repository at this point in the history
  • Loading branch information
ramirezsebas committed Jan 9, 2024
1 parent 981e863 commit 8278fed
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/app/widgets/footer.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_conf_web/app/services/url_service.dart';
import 'package:flutter_conf_web/gen/assets.gen.dart';
import 'package:flutter_conf_web/l10n/l10n.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:provider/provider.dart';

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

Future<void> launchUrlSocialMedia(String link) async {
final url = Uri.parse(link);
if (!await launchUrl(url)) {
throw Exception('Could not launch $url');
}
}

@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
Expand All @@ -23,10 +17,10 @@ class Footer extends StatelessWidget {
color: Colors.black,
child: size.width > 600
? _FooterDesktop(
launchUrlSocialMedia: launchUrlSocialMedia,
launchUrlSocialMedia: context.read<UrlService>().openUrl,
)
: _FooterMobile(
launchUrlSocialMedia: launchUrlSocialMedia,
launchUrlSocialMedia: context.read<UrlService>().openUrl,
),
);
}
Expand Down

0 comments on commit 8278fed

Please sign in to comment.