我有一个列表视图,其中加载了 api 中的图像,我注意到图像偶尔滚动时会持续消失几秒钟。这是仅在图像部分的代码:
Container(
padding: EdgeInsets.only(top:5.0,left:15.0,right:1.0,bottom:0.0),
constraints: new BoxConstraints.expand(
height: 130.0,
width: 150.0,
),
decoration: new BoxDecoration(
image: new DecorationImage(
image: NetworkImage(artworksAndEventsFinal[index]['thumbnail']),fit: BoxFit.cover,),
),
child: new Stack(
children: <Widget>[
new Positioned(
right: 0.0,
bottom: 0.0,
child: Container(
height: 24.0,
padding: EdgeInsets.only(top:5.0,left:10.0,right:5.0,bottom:5.0),
decoration: new BoxDecoration(
color: Theme.of(context).primaryColor,
),
child: new Text(artworksAndEventsFinal[index]['year'],
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 11.0,
color: Colors.white
)
),
)
),
new Positioned(
right: 3.0,
top: 0.0,
child: new Icon(Icons.favorite_border,color:
Colors.white,),
),
],
)
),
Run Code Online (Sandbox Code Playgroud)
我最近在 youtube ( https://www.youtube.com/watch?v=knMvKPKBzGE&t=3s ) 上观看了 felix Angelov 的 flutter_bloc 包 ( https://pub.dev/packages/flutter_bloc ) 演讲,非常棒!
我对在 dispose 方法中手动关闭块有一些困惑。我从演讲中听说,如果我们使用 flutter_bloc 包,我们就不必调用 bloc 的 dispose 方法,如果这是错误的,请纠正我。
提前致谢
我正在使用 laravel sainttum 为我的移动应用程序进行 API 身份验证。
我们如何限制每个用户的最大活跃代币数量?
目前,在personal_access_tokenssainttum 生成的表中,没有 user_id 引用。对于当前的表,想象一下如果用户无限制地登录和注销。我们将在表中创建 N 个新令牌。
我有以下列表,我想按日期时间重新排序/排序。
import 'package:intl/intl.dart';
//don't forget to add under dependencies pubspec.yml "intl: ^0.15.8"
List products = [];
//adding into the new list from raw api list
for(final item in rawProducts){
var parsedDate = DateTime.parse.(item['expiryDate']);
tmpArray = {
'id': item['id'],
'name': item['name'],
'price': item['price'],
'expiry': parsedDate
}
products.add(tmpArray);
}
}
List products = [
{id: 1242, name: milk, price: $5, expiry: 2019-11-25 00:00:00:000},
{id: 1242, name: egg, price: $2, expiry: 2019-11-22 00:00:00:000},
{id: 1243, name: bread, price: $3, expiry: 2019-11-22 00:00:00:000},
{id: …Run Code Online (Sandbox Code Playgroud) 我试图在laravel中使用分页.所以我尝试检索所有的交易并对其进行分页.我的流程就像你的参考视图 - > controller-> repository-> model.
myrepository:
public function getall(){
$this->transaction = Transaction::all();
return $this->transaction;
}
Run Code Online (Sandbox Code Playgroud)
myController的:
public function getall(){
$transactions = $this->transaction->getall()->paginate(10);
//dd($this->transaction);
return view('transactions', ['transactions' => $transactions]);
}
Run Code Online (Sandbox Code Playgroud)
在我的app.php服务提供商下我确定我有分页:Illuminate\Pagination\PaginationServiceProvider :: class,
但是没有别名.所以在我的控制器中我做了:使用Illuminate\Pagination;
我有一个列表,我试图在其中推送另一个列表,但它不断抛出错误
List Products;
for(final i productsFromApi){
var tmpArray = [];
tmpArray['name'] = i['name'];
tmpArray['price'] = i['price'];
tmpArray['quantity'] = i['quantity'];
Products.add(tmpArray);
}
print('final list of products');
print(products); // throws an error: add called on null
Run Code Online (Sandbox Code Playgroud)