小编Chy*_*erX的帖子

Flutter中如何设置PageView的初始页面?

我有一个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)

不幸的是,这对我没有帮助。

flutter flutter-layout flutter-pageview

16
推荐指数
3
解决办法
7582
查看次数

Flutter 是否有可能在文本上添加图像?

我一直在寻找使用图像作为背景的可能性Text我长期以来

文字剪切效果有点相似,但这不是我真正想要的东西。

事实上,我想要这样的东西。 在此输入图像描述

是否存在任何 Dart 包?谁能帮我提供一个想法或解决方案?

flutter flutter-plugin

10
推荐指数
1
解决办法
1302
查看次数

如何在颤振中绘制自定义形状

我只想画一个旋转轮。这样的圆怎么画? 在此处输入图片说明

dart flutter

8
推荐指数
1
解决办法
6252
查看次数

检查列表是否包含 dart 中对象的属性

我需要检查是否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)

上面的代码没有按预期工作,请帮助我找出问题所在。

dart

7
推荐指数
3
解决办法
2万
查看次数

如何以编程方式突出显示Android CalendarView中的多个日期

我需要在CalendaView中突出显示几个日期.应该是这样的,在此输入图像描述

我试过了setDate(),但它没有按我的意愿工作.请帮我找一个解决方案.提前致谢.

android calendarview

6
推荐指数
1
解决办法
9319
查看次数

如何将 Json 对象附加到 android 中现有的 json 文件中

我的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)

android json

5
推荐指数
1
解决办法
8296
查看次数

如何使用POST方法在android中使用Retrofit发送原始JSON

我想发布以下 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)

但无法达到我想要的,请帮助我实现我所需要的。提前致谢

android gson retrofit android-json

5
推荐指数
2
解决办法
5148
查看次数

在 Flutter 中将 BASE64 字符串转换为图像

我试过将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...

我怎么能摆脱这个问题?

dart flutter

4
推荐指数
1
解决办法
5008
查看次数

如何更新 JSON 文件数组中的特定对象?

我的 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)

我需要更新appointmentTitleapp_001appointmentId

我的功能是

String configFileString = "";

            File configFile = new File(getApplicationContext().getExternalFilesDir("/appointments"), "appointments.json");
            try {
                configFileString = …
Run Code Online (Sandbox Code Playgroud)

android json

3
推荐指数
1
解决办法
1866
查看次数

如何在 Flutter 中禁用 TabBar 项的突出显示和飞溅行为

我只想在点击选项卡项时禁用或更改highlightColorsplashColor行为?

我的代码段,

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)

指导我如何制作。

dart flutter

3
推荐指数
4
解决办法
2429
查看次数

Flutter DropdownButtonFormField 不显示在行中

我在行内并排添加一个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 相同,因为当前代码显示的下拉菜单高度较小。

flutter flutter-layout

2
推荐指数
1
解决办法
2743
查看次数

如何在谷歌地图android中显示当前位置的平滑移动

我正在实现一个地图导航应用程序。我每 1000 毫秒获取一次设备的当前位置并绘制一条折线,从当前位置到固定标记点。但是当在车内使用设备时,折线和当前位置更新不像优步或谷歌地图那样具有动画效果。它从一个点突然变成另一个点。

如何获得当前位置变化的平滑动画。

android google-maps android-mapview android-maps-v2

1
推荐指数
1
解决办法
3793
查看次数

如何自定义应用程序栏并将Imageview置于抖动中

我想设计一个给定图像的布局,

我需要设计一个这样的屏幕

我使用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 flutter-layout

1
推荐指数
1
解决办法
1907
查看次数