我无法获取bottom导航栏来加载Webview页面 这对我来说仍然是全新的,请指教。
children: <Widget>[
WebView(initialUrl:"http://app.com/index.php" ),
WebView(initialUrl:"http://app.com/tools.php" ),
WebView(initialUrl:"http://app.com/profile.php" ),
],
);
} ),
bottomNavigationBar: BottomNavyBar(
selectedIndex: _currentIndex,
onItemSelected: (index) {
setState(() => _currentIndex = index);
_pageController.jumpToPage(index);
},
items: <BottomNavyBarItem>[
BottomNavyBarItem(
title: Text('Home'),
icon: Icon(Icons.home),
),
BottomNavyBarItem(
title: Text('Tools'),
icon: Icon(Icons.settings)
),
BottomNavyBarItem(
title: Text('My account'),
icon: Icon(Icons.chat_bubble)
答案 0 :(得分:0)
我不确定_pageController在做什么,但是我想您可以在onItemSelected方法中对网址进行硬编码。这是一个示例:
_onSelectBottomItem(int index) {
if (index == 0) {
webView.loadUrl("url1");
} else if (index == 1) {
webView.loadUrl("url2");
} else if (index == 2) {
webView.loadUrl("url3");
}
setState(() {
_currentIndex = index;
});
}
您可以在onItemSelected方法中调用_onSelectBottomItem。希望这会有所帮助。