看来我找不到合适的术语来搜索我的问题。我现在有一个几乎可以解决一个问题的应用程序。首先,我想先解释一下该应用程序。该应用程序是一个Webview应用程序,底部导航栏上有5个标签。我正在使用官方Flutter开发团队webview_flutter
我有两个问题,顺便说一句
现在剩下的问题是,当我登录到在使用webview的选项卡之一中设置的网址时,它会产生
(1)我用来登录的标签中的错误(下图,由于某种原因该错误不会再次出现在我的模拟器上(它是第一次发生),但它会出现在手机上),并且不会自动重定向到URL ive组
(2)并非所有选项卡都会自动刷新以检测登录事件(我需要浏览网站的网址,然后返回以检测登录事件(这是我不想发生的事情)
以下是我的代码:
主镖
import 'package:syncshop_webview/widgets/cart_page.dart';
import 'package:syncshop_webview/widgets/categories_page.dart';
import 'package:syncshop_webview/widgets/home_page.dart';
import 'package:syncshop_webview/widgets/profile_account.dart';
import 'package:syncshop_webview/widgets/search_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return MyAppState();
}
}
class MyAppState extends State<MyApp> {
int _selectedPage = 2;
final _pageOptions = [
CategoriesPage(),
SearchPage(),
HomePage(),
CartPage(),
ProfileAccount(),
];
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Sync Shop',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: IndexedStack(
index: _selectedPage,
children: _pageOptions,
),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _selectedPage,
onTap: (int index) {
setState((){
_selectedPage = index;
});
},
items: [
BottomNavigationBarItem(icon: Icon(Icons.category), title: Text("Categories"),
),
BottomNavigationBarItem(icon: Icon(Icons.search), title: Text("Search"),
),
BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("Home"),
),
BottomNavigationBarItem(icon: Icon(Icons.shopping_cart), title: Text("Cart"),
),
BottomNavigationBarItem(icon: Icon(Icons.account_circle), title: Text("Profile"),
),
],
),
),
);
}
}
我的标签之一,特别是用户应登录的位置
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class ProfileAccount extends StatefulWidget {
@override
_ProfileAccountState createState() => _ProfileAccountState();
}
class _ProfileAccountState extends State<ProfileAccount> with AutomaticKeepAliveClientMixin<ProfileAccount>{
WebViewController _myController;
Widget build(BuildContext context) {
super.build(context);
return SafeArea(
child: Scaffold(
body: WebView(
initialUrl: 'https://syncshop.online/en/login',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller) {
_myController = controller;
},
onPageFinished: (initialUrl) {
_myController.evaluateJavascript("document.getElementsByClassName('footer-container')[0].style.display='none';");
},
),
),
);
}
@override
bool get wantKeepAlive => true;
}
这是API级别28或更高版本中的问题。他们android:usesCleartextTraffic
出于安全考虑而禁用。在这里您可以找到解决方案。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句