说我有两条路由 / firstRoute 和 / secondRoute ,分别用于小部件 FirstRoute 和 SecondRoute 。我正在将带有某些参数的命名路由推入堆栈,就像这样……
Navigator.pushNamed(
context,
"/secondRoute",
arguments: <String, String>{"key" : "value"},
)
现在如何在 SecondRoute 中使用此值? 看了看文档,但没有提及。
答案 0 :(得分:2)
为参数创建类:
class ScreenArguments {
final String title;
final String message;
ScreenArguments(this.title, this.message);
}
并在小部件中提取它们:
class ExtractArgumentsScreen extends StatelessWidget {
static const routeName = '/extractArguments';
@override
Widget build(BuildContext context) {
// Extract the arguments from the current ModalRoute settings and cast
// them as ScreenArguments.
final ScreenArguments args = ModalRoute.of(context).settings.arguments;
return Scaffold(
appBar: AppBar(
title: Text(args.title),
),
body: Center(
child: Text(args.message),
),
);
}
}
用于发送参数:
Navigator.pushNamed(
context,
ExtractArgumentsScreen.routeName,
arguments: ScreenArguments(
'Extract Arguments Screen',
'This message is extracted in the build method.',
),
);
答案 1 :(得分:0)
使用Row
在{overflowX: "auto"}
的构建方法中:
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver import ActionChains
#Incognito Mode
option=webdriver.ChromeOptions()
option.add_argument("--incognito")
#Open Chrome
driver=webdriver.Chrome(executable_path="C:/Users/chromedriver.exe",chrome_options=option)
#url I want to visit.
lists=['https://www.tripadvisor.com/VacationRentalReview-g30196-d6386734-Hot_51st_St_Walk_to_Mueller_2BDR_Modern_sleeps_7-Austin_Texas.html']
for k in lists:
driver.get(k)
html =driver.page_source
soup=BeautifulSoup(html,"html.parser")
time.sleep(3)
listing=soup.find_all("div", class_="review-container")
for i in range(len(listing)):
try:
#First, I tried this but didn't work.
#link = driver.find_element_by_link_text('More')
#driver.execute_script("arguments[0].click();", link)
#Second, I tried ActionaChains but didn't work.
ActionChains(driver).move_to_element(i).click().perform()
except:
pass
text_review=soup.find_all("div", class_="prw_rup prw_reviews_text_summary_hsx")
text_review_inside=text_review[i].find("p", class_="partial_entry")
review_text=text_review_inside.text
print (review_text)