我想放弃SnackBar上SnackBarAction的onPressed方法。我尝试过Navigator.of(context).pop();但SnackBar不排除屏幕变黑。
这是代码:
void showInSnackBar(String value) {
homeScaffoldKey.currentState.showSnackBar(new SnackBar(content: new Text(value),
action: SnackBarAction(
label: 'Dissmiss',
textColor: Colors.yellow,
onPressed: () {
// Navigator.of(context).pop();
},
),));
}
Run Code Online (Sandbox Code Playgroud) 我要使我的TextField高度与我的容器高度相同。请检查以下代码,让我知道如何使TextField容器的match_parent。我已经检查了这个问题,在flutter中相当于wrap_content和match_parent?但没有找到任何解决方案。我需要将TextField容器的高度和宽度全部取整。
new Container(
height: 200.0,
decoration: new BoxDecoration(
border: new Border.all(color: Colors.black)
),
child: new SizedBox.expand(
child: new TextField(
maxLines: 2,
style: new TextStyle(
fontSize: 16.0,
// height: 2.0,
color: Colors.black
),
decoration: const InputDecoration(
hintText: "There is no data",
contentPadding: const EdgeInsets.symmetric(vertical: 40.0),
)
),
),
)
Run Code Online (Sandbox Code Playgroud)
请检查下面的屏幕截图,我需要TextField全力以赴Container
我正在尝试模仿类似于附加图像的搜索视图,但出现以下错误。我可以使用 ListTile 实现这一点,但我无法为图标或 TextField 设置填充。所以我试图使用 Row 小部件来实现这一点。请查看我的代码并帮助我绘制此搜索栏。
I/flutter (19181): The following assertion was thrown during
performLayout():
I/flutter (19181): BoxConstraints forces an infinite width.
I/flutter (19181): These invalid constraints were provided to
RenderAnimatedOpacity's layout() function by the
I/flutter (19181): following function, which probably computed
the invalid constraints in question:
I/flutter (19181): _RenderDecoration._layout.layoutLineBox (package:flutter/src/material/input_decorator.dart:767:11)
I/flutter (19181): The offending constraints were:
I/flutter (19181): BoxConstraints(w=Infinity, 0.0<=h<=46.0)
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
new Container(
height: 70.0,
color: Theme.of(context).primaryColor,
child: new Padding(
padding: const EdgeInsets.all(8.0),
child: new Card(
child: new …Run Code Online (Sandbox Code Playgroud) 我从服务器获取数据时正在调用此对话框。此对话框周围有空白。我可以删除对话框周围的空白区域。这是我的代码。
var bodyProgress = new Container(
decoration: new BoxDecoration(
color: Colors.blue[200],
borderRadius: new BorderRadius.circular(10.0)
),
width: 300.0,
height: 200.0,
//color: Colors.blue,
alignment: AlignmentDirectional.center,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Center(
child: new SizedBox(
height: 50.0,
width: 50.0,
child: new CircularProgressIndicator(
value: null,
strokeWidth: 7.0,
),
),
),
new Container(
margin: const EdgeInsets.only(top: 25.0),
child: new Center(
child: new Text(
"Signing up...",
style: new TextStyle(
color: Colors.white
),
),
),
),
],
),
);
Run Code Online (Sandbox Code Playgroud)
在这里,我称此对话框。我尝试过AlertDialog()和SimpleDialog()都存在相同的问题。
showDialog(context: context, …Run Code Online (Sandbox Code Playgroud) 如何在flutter的下拉菜单中设置初始值?
在下拉菜单中,我要设置初始值,当前显示的提示值为“选择语言”。我需要显示初始值。就像我的初始值是English一样,它应该是我的下拉菜单中的选定项。
下面是我的代码:
new DropdownButtonHideUnderline(
child: new DropdownButton<Language>(
hint: new Text("Select Language"),
value: selectedLanguage,
onChanged: (Language newValue) {
applic.onLocaleChanged(new Locale(newValue.languageCode,''));
setState(() {
selectedLanguage = newValue;
});
},
items: listLanguage.map((Language language) {
return new DropdownMenuItem<Language>(
value: language,
child: new Text(
language.languageName ,
style: new TextStyle(color: Colors.black),
),
);
}).toList(),
),
)
Run Code Online (Sandbox Code Playgroud)
我的清单初始化为:
List<Language> listLanguage =
<Language> [new Language("English", "en"),
new Language("French", "fr"),
new Language("Hindi", "hi"),
];
Language selectedLanguage;
Run Code Online (Sandbox Code Playgroud)
我正在使用购物车应用程序并使用 flutter_redux 来更新我的购物车。一切正常,但我的购物车列表中出现重复项目,如何删除这些重复条目并添加数量。我想获得包含物品和数量的清单。请帮助我使用这段代码,我可以在哪里添加逻辑并使用已删除的重复项过滤列表。
这是我的代码:
carItemReducer.dart
List<CartItem> cartItemReducer(List<CartItem> items, dynamic action)
{
if(action is AddItemAction)
{
return addItem(items, action);
}
else if (action is DeleteItemAction)
{
return deleteItem(items, action);
}
return items;
}
List<CartItem> addItem(List<CartItem> items, AddItemAction action)
{
return new List.from(items)..add(action.item);
}
List<CartItem> deleteItem(List<CartItem> items, DeleteItemAction action)
{
return new List.from(items)..remove(action.item);
}
Run Code Online (Sandbox Code Playgroud)
从此代码将商品添加到我的购物车:
Widget futureWidget()
{
return new FutureBuilder<List<ModelProductDetail>>(
future: getDetailProductFuture(),
builder: (BuildContext context, AsyncSnapshot snapshot){
if(snapshot.hasData)
{
Widget addRemoveButtonRedux = new StoreConnector<
List<CartItem>, OnItemAddedCallback>(
converter: (store)
=>(itemName) => store.dispatch( …Run Code Online (Sandbox Code Playgroud) 我有以下角度6中的表,该表是从数据库动态获取的。
<table *ngIf="attendanceModel.length > 0; else attendanceModel_else" class="table table-responsive" id="table">
<thead>
<tr>
<th>Name</th>
<th>Designation</th>
<th>Morning Session</th>
<th>Evening Session</th>
<th>Total Hours</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let attendance of attendanceModel | groupBy:'employee_id'">
<tr>
<td colspan="6" class="text-center text-muted"> « Name: {{ attendance.key }} » </td>
</tr>
<tr *ngFor="let attendance of attendance.value">
<td>{{attendance.employee_id.profile.first_name}} {{attendance.employee_id.profile.last_name}}</td>
<td>{{attendance.employee_id.designation}}</td>
<td>{{attendance.morning_session}}</td>
<td>{{attendance.evening_session}}</td>
<td>{{attendance.total_hours | number:'1.0-1' }}</td>
<td *ngIf="attendance.status == 'Verified'; else inactive_else">
<a class="btn btn-link text-success p-0" (click)="notVerify(attendance._id)">{{attendance.status}}</a>
</td>
<ng-template #inactive_else>
<td *ngIf="attendance.status == 'Not Verified'">
<a class="btn …Run Code Online (Sandbox Code Playgroud)