【发布时间】:2021-12-28 09:37:14
【问题描述】:
我想让 WebView 的底部(包括广告)无需触摸/点击即可点击。我的 WebView 在其底部包含一个浮动广告。我想让它自动点击而不是一次又一次地点击它。我使用了 IgnorePointer 类。我的代码的某些部分已被注释,您也可以检查它。 (注:我这样做只是为了学习) 这是我的代码:
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class HomeScreen extends StatelessWidget{
@override
Widget build(BuildContext context) {
final _key = UniqueKey();
final height=MediaQuery.of(context).size.height;
// return CustomScrollView(
//
// slivers: <Widget>[
// SliverAppBar(
// title: const Text("Software Testing Help"),
// floating: true,
// ),
// SliverFillRemaining(
// child: WebView(initialUrl: "https://www.softwaretestinghelp.com/digital-marketing-software/"),
// )
// ],
// );
return Scaffold(
appBar: AppBar(
toolbarHeight: height*0.08,
backgroundColor: Colors.black,
title: Center(child: Text('Software Testing Help', style: TextStyle(
color: Colors.white
),)),
),
body:
Stack(
children: [
Container(
height: height*0.90,
child: Expanded(
child: WebView(
initialUrl: 'https://www.softwaretestinghelp.com/digital-marketing-software/',
key: _key,
javascriptMode: JavascriptMode.unrestricted,
),
)
),
Positioned(
bottom:0,
left: 10,
child: GestureDetector(
onTap: (){
Scaffold.of(context).showSnackBar(SnackBar(
content: Text('Ad is clicked'),
));
},
child: IgnorePointer(
ignoring: true,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.blue
)
),
height: 100,
width: 100,
),
),
),
)
]
)
);
}
}
【问题讨论】:
标签: flutter button webview onclick click