我有一个DownloadsService类使用包处理文件下载dio。我想听一下我的ViewModel类中实现类downloadFile内方法的下载进度DownloadService。我该怎么做呢?
这是我的DownloadsService课程代码片段:
class DownloadsService {
final String urlOfFileToDownload = 'http://justadummyurl.com/'; //in my actual app, this is user input
final String filename = 'dummyfile.jpg';
final String dir = 'downloads/$filename'; //i'll have it saved inside internal storage downloads directory
void downloadFile() {
Dio dio = Dio();
dio.download(urlOfFileToDownload, '$dir/$filename', onReceiveProgress(received, total) {
int percentage = ((received / total) * 100).floor(); //this is what I want to listen to from my ViewModel …Run Code Online (Sandbox Code Playgroud) 我在 mysql 中有这个数据库模式:
users_tbl
--------------------------------------------
id | first_name | last_name
--------------------------------------------
1 | Jon | Doe
2 | Mark | Smith
address_tbl
------------------------------------------------------------
id | address | city | user_id
------------------------------------------------------------
1 | some address | some city | 1
Run Code Online (Sandbox Code Playgroud)
然后,我想使用 TypeOrm 的 queryBuilder 来获取 Jon Doe 的地址。
我的原始 SQL 查询:
SELECT users.first_name, users.last_name, address.address, address.city FROM users INNER JOIN address ON address.user_id=users.id
我的 TypeOrm 查询生成器:
const users = await this.userRepo
.createQueryBuilder('users')
.select('users.first_name', 'fName')
.addSelect('users.last_name', 'lName')
.addSelect('adr.address', 'address')
.addSelect('adr.city', 'city') …Run Code Online (Sandbox Code Playgroud)