Я добавил нижнюю панель навигации, используя пакет CubertoBottomBar. Я хочу запустить новый URL-адрес в другом браузере с помощью пакета url_launcher, когда я реализую то же самое, он выдает мне ошибку, так как тип «Future» не является подтипом типа «Widget», пожалуйста, помогите мне исправить проблему.
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _currentIndex = 0;
Color inactiveColor = Colors.white;
String currentTitle = "Home";
Color currentColor = Colors.white;
final List<Widget> _children = [
HomePage(),
Contact(),
_urlLauncher()
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: _children[_currentIndex],
bottomNavigationBar: CubertoBottomBar(
barBackgroundColor: Colors.orange,
inactiveIconColor: inactiveColor,
tabStyle: CubertoTabStyle.STYLE_FADED_BACKGROUND,
selectedTab: _currentIndex,
tabs: [
TabData(iconData: Icons.home, title: "Home", tabColor: Colors.white),
TabData(iconData: Icons.phone, title: "Contact", tabColor: Colors.white),
TabData(iconData: Icons.person_outline, title: "Register", tabColor: Colors.white),
],
onTabChangedListener: (position, title, color) {
setState(() {
_currentIndex = position;
currentTitle = title;
currentColor = color;
});
},
),
);
}
void onTabTapped(int index) {
setState(() {
_currentIndex = index;
});
}
static _urlLauncher() async{
const url = 'https://flutter.dev';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
}