import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
// app build process is triggered here
void main(){
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
Future<void> _sendingMails() async {
var _url = Uri.parse("mailto:[email protected]");
if(!await launchUrl(_url, mode: LaunchMode.externalApplication)) {
throw Exception('Could not launch $_url');
}
}
Future<void> _sendingSMS() async {
var _url = Uri.parse("sms:1234567890");
if (!await launchUrl(_url, mode: LaunchMode.externalApplication)) {
throw Exception('Could not launch $_url');
}
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: const Text('Geeks for Geeks'),
backgroundColor: Colors.green,
foregroundColor: Colors.white,
),
body: SafeArea(
child: Center(
child: Column(
children: [
Container(
height: 200.0,
),
const Text(
'Welcome to GFG!',
style: TextStyle(
fontSize: 35.0,
color: Colors.green,
fontWeight: FontWeight.bold,
),
),
Container(
height: 20.0,
),
const Text(
'For any Queries, Mail us',
style: TextStyle(
fontSize: 18.0,
color: Colors.green,
),
),
Container(
height: 10.0,
),
ElevatedButton(
onPressed: _sendingMails,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
foregroundColor: Colors.white
),
child: const Text('Here'),
), // ElevatedButton
Container(
height: 20.0,
),
const Text(
'Or Send SMS',
style: TextStyle(
fontSize: 18.0,
color: Colors.green,
),
),
Container(
height: 10.0,
),
ElevatedButton(
onPressed: _sendingSMS,
style:ElevatedButton.styleFrom(
backgroundColor: Colors.green,
foregroundColor: Colors.white
),
child: const Text('Here'),
), // ElevatedButton
],
),
),
),
),
);
}
}