[英]tappable Horizontal list view in flutter. how do i make a clickable list view with images from the list
[英]I want to make a button automatically clickable without a tap in flutter. I'm also using WebView flutter:
我想讓 WebView 的底部(包括廣告)無需觸摸/點擊即可點擊。 我的 WebView 在其底部包含一個浮動廣告。 我想讓它自動點擊而不是一次又一次地點擊它。 我使用了 IgnorePointer class。 我的代碼的某些部分已被注釋,您也可以檢查它。 (注意:我這樣做只是為了學習)這是我的代碼:
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,
),
),
),
)
]
)
);
}
}
您可以通過計時器自動執行此操作,一段時間后此計時器將調用您的 function。 像這樣的東西:
bool? isLoading;
addClickedRunner() {
Timer(
Duration(seconds: 5), //example: after 5sec will call your task
() async {
isLoading = true; //to show circularProgressIndicatior for your button
Scaffold.of(context).showSnackBar(SnackBar(
content: Text('Ad is clicked'),));
isLoading = false;
},
);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.