Hi Team,
I am creating an app in which when you open the flutter app it's launching the URL of the website in the chrome app. But when I pressed back from the chrome app I also need to kill the flutter app also.
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher_string.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
websitelaunch();
super.initState();
}
bool x = false;
void websitelaunch() async {
const url = 'https://www.google.com';
if (await canLaunchUrlString(url.toString())) {
x = await launchUrlString(
url,
mode: LaunchMode.externalApplication,
);
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Website launch from logo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: Container(),
),
);
}
}
This is my current main.dart file code and I used the package URL launcher plugin for the launch URL.
url_launcher: ^6.1.4
As you can see the app launches the google URL in chrome. But when the back button pressed the initial white screen of the flutter app it's still open.
Please help me how to kill the flutter app when we came back again to the flutter app.