我有一个PageView
有四页的。我想从第三页开始。这意味着当用户向上滚动时有两页可用,当用户向下滚动时有一页可用。
我试过:
home: PageView(
controller: MyPageController(),
children: [Page1(), Page2(), Page3(), Page4()],
scrollDirection: Axis.vertical,
),
Run Code Online (Sandbox Code Playgroud)
和:
class MyPageController extends PageController {
@override
int get initialPage => 3;
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这对我没有帮助。
我需要检查是否myItemsList
包含myitem.itemId
,如果存在需要添加itemQuantity
,如果不存在需要添加myitem
对象到myItemsList
。
List<MyItem> myItemsList = new List();
MyItem myitem = new MyItem (
itemId: id,
itemName: name,
itemQuantity: qty,
);
if (myItemsList.contains(myitem.itemId)) {
print('Allready exists!');
} else {
print('Added!');
setState(() {
myItemsList.add(myitem);
});
}
Run Code Online (Sandbox Code Playgroud)
MyItem
班级
class MyItem {
final String itemId;
final String itemName;
int itemQuantity;
MyItem ({
this.itemId,
this.itemName,
this.itemQuantity,
});
}
Run Code Online (Sandbox Code Playgroud)
上面的代码没有按预期工作,请帮助我找出问题所在。
我的json文件包含,
{
"appointments": [
{
"appointmentId": "app_001",
"appointmentTitle": "Appointment Title1",
"appointmentDate": "2017-11-25",
"appointmentTime": "10:30",
"appointmentStatus": "active",
"appointmentType": "meeting",
"reminder": {
"type": "notification",
"time": "10:15",
"status": "off"
},
"appointmentDescription": "blablablablabla1"
},
{
"appointmentId": "app_002",
"appointmentTitle": "AppointmentTitle2",
"appointmentDate": "2017-11-26",
"appointmentTime": "09:00",
"appointmentStatus": "done",
"appointmentType": "exam",
"reminder": {
"type": "alarm",
"time": "08:45",
"status": "on"
},
"appointmentDescription": "blablablablabla2"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我需要将另一个 jsonobject 放入数组,输出应该是这样的,
{
"appointments": [
{
"appointmentId": "app_001",
"appointmentTitle": "Appointment Title1",
"appointmentDate": "2017-11-25",
"appointmentTime": "10:30",
"appointmentStatus": "active",
"appointmentType": "meeting",
"reminder": {
"type": …
Run Code Online (Sandbox Code Playgroud) 我想发布以下 JSON,
{
"name": {
"firstName": "f_name",
"lastName": "l_name"
},
"password": "mypassword123",
"email": "test.mail@gmail.com"
}
Run Code Online (Sandbox Code Playgroud)
接口内部的注册方法是,
@POST("user/createuser")
Call<RegisterResponseModel> register(@Body RegisterModel body);
Run Code Online (Sandbox Code Playgroud)
使用注册方法,如,
Name name = new Name("f_name", "l_name");
RegisterModel registerModel = new RegisterModel(name, "mypassword123", "test.mail@gmail.com");
Call<RegisterResponseModel> res = apiService.register(registerModel);
Run Code Online (Sandbox Code Playgroud)
但无法达到我想要的,请帮助我实现我所需要的。提前致谢
我试过将BASE64
字符串解码为Uint8List
Uint8List _bytes =
base64.decode('data:image/jpeg;base64,/9j/4AAQ .........');
Image.memory(_bytes);
Run Code Online (Sandbox Code Playgroud)
但是得到错误,(字符错误:)
无效字符(在字符 5 处)数据:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUSEhMVFRUV...
我怎么能摆脱这个问题?
我的 json 文件在内部存储中的格式是这样的,
{
"appointments": [
{
"appointmentId": "app_001",
"appointmentTitle": "Appointment Title1",
"appointmentDate": "2017-11-25",
"appointmentTime": "10:30",
"appointmentStatus": "active",
"appointmentType": "meeting",
"reminder": {
"type": "notification",
"time": "10:15",
"status": "off"
},
"appointmentDescription": "blablablablabla1"
},
{
"appointmentId": "app_002",
"appointmentTitle": "AppointmentTitle2",
"appointmentDate": "2017-11-26",
"appointmentTime": "09:00",
"appointmentStatus": "done",
"appointmentType": "exam",
"reminder": {
"type": "alarm",
"time": "08:45",
"status": "on"
},
"appointmentDescription": "blablablablabla2"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我需要更新appointmentTitle
其app_001
值appointmentId
我的功能是
String configFileString = "";
File configFile = new File(getApplicationContext().getExternalFilesDir("/appointments"), "appointments.json");
try {
configFileString = …
Run Code Online (Sandbox Code Playgroud) 我只想在点击选项卡项时禁用或更改highlightColor
和splashColor
行为?
我的代码段,
SliverAppBar(
backgroundColor: MyColors.darkGreen,
elevation: 0.0,
automaticallyImplyLeading: false,
bottom: TabBar(
isScrollable: true,
unselectedLabelColor: Colors.grey,
labelColor: Colors.white,
onTap: (int itemIndex) {},
indicatorSize: TabBarIndicatorSize.tab,
indicator: BubbleTabIndicator(
indicatorHeight: 25.0,
indicatorColor: Colors.white38,
tabBarIndicatorSize: TabBarIndicatorSize.tab,
),
tabs: tabs,
controller: _tabController,
),
pinned: true,
floating: false,
title: _titleWidget,
),
Run Code Online (Sandbox Code Playgroud)
指导我如何制作。
我在行内并排添加一个DropdownFormField
和。TextFormField
这就是构建函数的样子
Widget build(BuildContext context) {
return Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
DropdownButton(
hint: new Text('Select Gender'),
items: _salutations,
value: client.salutation,
),
SizedBox(width: 20),
new Expanded(
child: TextFormField(
decoration: InputDecoration(labelText: 'Name'),
validator: (value) {
return value.isEmpty ? 'Empty name.' : '';
},
),
),
]
)
],
)
),
);
}
Run Code Online (Sandbox Code Playgroud)
该代码当前显示,因为它是 DropdownButton。但如果我将其更改为 DropdownButtonFormField,只要它位于 Row() 中,它就不会显示。为什么是这样?
我希望使用 DropdownButtonFormField ,以便 Dropdown 的高度与 TextFormField 相同,因为当前代码显示的下拉菜单高度较小。
我正在实现一个地图导航应用程序。我每 1000 毫秒获取一次设备的当前位置并绘制一条折线,从当前位置到固定标记点。但是当在车内使用设备时,折线和当前位置更新不像优步或谷歌地图那样具有动画效果。它从一个点突然变成另一个点。
如何获得当前位置变化的平滑动画。
我想设计一个给定图像的布局,
我使用PreferredSize,我的代码是
PreferredSize(
preferredSize: Size.fromHeight(200.0),
child: AppBar(
// title: Text('Profile'),
title: Row(
children: <Widget>[
Icon(Icons.account_circle, size: 150.0),
Text('data'),
],
),
bottom: TabBar(
tabs: [
.
.
],
),
),
),
Run Code Online (Sandbox Code Playgroud)
输出与预期的设计不同,请检查此内容,
我该如何解决?
flutter ×7
android ×5
dart ×4
json ×2
android-json ×1
calendarview ×1
google-maps ×1
gson ×1
retrofit ×1