我有一个由几个带有尾随图标的 sListView组成的。ListTile图标的颜色应根据用户的点击从透明变为绿色。但是,UI 不会根据用户交互进行更新。
是ServiceModel这样的。
class ProviderService extends ChangeNotifier {
final List<String> totalNames = ['Somesh', 'Tarulata', 'Indranil', 'Satyajyoti', 'Biswas', 'Sajal', 'Kumar', 'Slipa', 'Sonam', 'Neelam'];
List<String> _selectedNames = [];
List<String> get selectedNames => _selectedNames;
void updateselectedNames(String name) {
bool isExists = _selectedNames.contains(name);
if (isExists)
_selectedNames.remove(name);
else
_selectedNames.add(name);
notifyListeners();
}
}
Run Code Online (Sandbox Code Playgroud)
事情ListView是这样的。
class Members extends StatelessWidget {
@override
Widget build(BuildContext context) {
ProviderService plService = Provider.of<ProviderService>(context, listen: false);
return Scaffold(
body: SafeArea(
child: Selector<ProviderService, List<String>>( …Run Code Online (Sandbox Code Playgroud) 我被要求在工作中使用 websocket 和 php Ratchet 进行 api 调用。由于我对websocket完全不熟悉,所以我通过google和观看youtube视频来解决这个问题,但是我搜索的越多,我就越觉得用websocket调用api是不可能的。
是我遗漏了什么还是websocket调用api真的不可能?如果可能的话,您能给我举个例子吗?
我知道我可能听起来很尴尬,因为我对网络套接字没有深入的了解,英语甚至不是我的母语,但我真的很绝望,请帮助我
我正在尝试编写一个程序,该程序将为我提供一些不同股票的股价,但是当我运行我的程序时,它返回 116.71,而雅虎财经在页面和 HTML 中将其显示为 117.96(在写这个)。知道发生了什么事吗?页面在这里。代码如下:
from bs4 import BeautifulSoup
import requests
url = 'https://finance.yahoo.com/quote/VTSAX?p=VTSAX&.tsrc=fin-srch'
page = requests.get(url)
soup = BeautifulSoup(page.text, 'html.parser')
price = soup.find('fin-streamer', {'class': 'Fw(b) Fz(36px) Mb(-4px) D(ib)'}).text
print(price)
Run Code Online (Sandbox Code Playgroud) 在vaadin Flow中,M是标准尺寸,大多数元素默认使用M。如何改为使用S作为标准尺寸(字体大小和行高)?我也想更改空间(大小、均匀、宽度和高度)以使用 S。
据说在C++的构造函数中,只要对象还没有构造完成,就不应该调用虚函数,否则会抛出“纯虚函数调用错误”。所以我尝试了这个:
#include<stdio.h>
class A{
virtual void f() = 0;
};
class A1 : public A{
public:
void f(){printf("virtual function");}
A1(){f();}
};
int main(int argc, char const *argv[]){
A1 a;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在 Windows 上用 g++ 编译它,它可以工作并打印
virtual function
Run Code Online (Sandbox Code Playgroud)
那么如何让我的程序抛出“纯虚函数调用”异常呢?
谢谢!
我刚刚安装了 Ubuntu 8.04 和 Eclipse。
我制作了一个非常简单的Hello World程序,以确保一切顺利运行。当我尝试使用 Scanner 类获取一些用户输入时,我遇到了一个非常奇怪的错误。
我的代码:
import java.util.Scanner;
class Test {
public static void main (String [] args) {
Scanner sc = new Scanner(System.in);
System.out.println("hi");
}
}
Run Code Online (Sandbox Code Playgroud)
错误信息
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Scanner cannot be resolved to a type
Scanner cannot be resolved to a type
at test.main(test.java:5)
Run Code Online (Sandbox Code Playgroud) 嗨,我正在学习 React,当我制作这个例子时,我感到有些好奇。这段代码就是向newsapi发送get请求,并接收结果。我使用了自定义钩子。
// *** this is where I use custom hook. "usePromise" is custom hook. *** //
function NewsList({ category }) {
const [loading, response, error] = usePromise(() => {
console.log("how many will it run?")
const query = category === 'all' ? '' : `&category=${category}`;
return axios.get(
`https://newsapi.org/v2/top-headlines?country=kr${query}&apiKey=044c3c345f28417380cd3ea946ac8641`
);
},[category]);
console.log(loading);
...
Run Code Online (Sandbox Code Playgroud)
我写了 console.log("how much will it run?") 来检查这个函数将运行多少个。还有console.log(loading)来检查加载将被更改的次数
// *** this is custom hook's code *** //
export default function usePromise(promiseCreator, deps) {
const [loading, setLoading] = …Run Code Online (Sandbox Code Playgroud) 我有一个包含这样的列的表(简化):
\n| ... | ... | Venter p\xc3\xa5 s\xc3\xb8ker | ... |\n| ... | ... | Ikke p\xc3\xa5begynt | ... |\nRun Code Online (Sandbox Code Playgroud)\n该表有 21 行。
\n相关列可以按字母顺序、降序或升序排序。
\n我想做的是让 Cypress 验证排序、升序和降序。
\n到目前为止我所得到的:
\ncy.get([data-e2e-selector=tabell]).get('[data-e2e-selector=kolonne]')\n .then(items => {\n const unsortedItems = items.map((index, html) => Cypress.$(html).text()).get();\n const sortedItems = unsortedItems.slice().sort()\n expect(unsortedItems, 'Items are sorted').to.deep.equal(sortedItems);\n });\nRun Code Online (Sandbox Code Playgroud)\n我想做的是从列中获取所有项目并将它们存储在列表中。然后创建一个包含相同项目但已排序的列表。然后比较两者。我已经成功地对日期戳(数字)做了类似的事情,但按字母顺序排序似乎让我困惑。
\n上面的代码会导致此错误(升序或降序相同):
\nassert expected Items are sorted: to deeply equal [ Array(21) ]\nRun Code Online (Sandbox Code Playgroud)\n为了验证我是否确实将元素放入列表中 - 如果我比较 unsortedItems[] 和sortedItems[] 列表的第一个或最后一个项目,它们是相同的:
\nexpect(unsortedItems, …Run Code Online (Sandbox Code Playgroud) 为什么它不起作用?
从 STATION 查询以元音 (a, e, i, o, u) 结尾的 CITY 名称列表。我们的结果不能包含重复项。
SELECT DISTINCT CITY FROM STATION
WHERE CITY LIKE '%A' OR CITY LIKE '%E' OR LIKE '%I' LIKE '%O' OR LIKE '%U'
ORDER BY CITY;
Run Code Online (Sandbox Code Playgroud)
正确的查询是什么?
给定文件名列表,我们希望将所有扩展名为 .hpp 的文件重命名为扩展名 h。为此,我们希望生成一个名为 newfilenames 的新列表,其中包含新文件名。使用您迄今为止学到的任何方法填充代码中的空白,例如 for 循环或列表推导式。
filenames = ["program.c", "stdio.hpp", "sample.hpp", "a.out", "math.hpp", "hpp.out"]
# Generate newfilenames as a list containing the new filenames
# using as many lines of code as your chosen method requires.
Run Code Online (Sandbox Code Playgroud)
print(newfilenames)
# Should be ["program.c", "stdio.h", "sample.h", "a.out", "math.h", "hpp.out"]
Run Code Online (Sandbox Code Playgroud) python ×2
alphabetical ×1
c++ ×1
call ×1
cypress ×1
eclipse ×1
flutter ×1
fonts ×1
function ×1
java ×1
list ×1
mysql ×1
php ×1
phpwebsocket ×1
prefect ×1
pure-virtual ×1
ratchet ×1
react-hooks ×1
reactjs ×1
size ×1
sorting ×1
syntax ×1
task ×1
ubuntu ×1
vaadin ×1
vaadin-flow ×1
virtual ×1
web-scraping ×1
websocket ×1