Trying to display the title of the webpage in the AppBar using the getTitle() method of webview_flutter.
It seems to work intermittently when the Hot reload is used on the debug bar but when I navigate to another page, it doesn't update.
Here is what I've tried
@override
Widget build(BuildContext context) {
var appBarWebpageTitle = FutureBuilder(
future: controller.getTitle(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text("${snapshot.data}");
} else {
return Text("Loading");
}
},
);
return Scaffold(
appBar: AppBar(
title: appBarWebpageTitle,
backgroundColor: const Color.fromARGB(255, 0, 0, 0),
actions: [
PopupMenuButton(itemBuilder: (context) {
return [
const PopupMenuItem<int>(
value: 0,
child: Text("Dashboard"),
),
];
}, onSelected: (value) {
if (value == 0) {
// print("My account menu is selected.");
}
}),
],
),
body: WebViewWidget(
controller: controller,
),
);
}
}