dart开发Android服务,关于android:在Flutter应用中使用由swagger生成的Dart代码生成的Web服务...

我正在尝试使用Flutter开发一个移动应用程序,我使用swagger生成了包含所有Web服务的Dart文件代码生成。我想从Web服务中获取所有用户的列表。 在屏幕上,我想为每个用户显示:图像,名字,姓氏和电子邮件。 我已经在main.dart中准备了如下的UI:

import 'package:flutter/material.dart';

import './utility.dart';

void main() => runApp(ListUserApp());

class ListUserApp extends StatelessWidget {

@override

Widget build(BuildContext context) {

return MaterialApp(

title: 'User List 4Motors',

home: ListUserScreen(),

);

}

}

class ListUserScreen extends StatefulWidget {

@override

State createState() {

return ListUserScreenState();

}

}

class ListUserScreenState extends State {

@override

Widget build(BuildContext context) {

return MaterialApp(

theme: ThemeData(

primarySwatch: Colors.indigo,

),

home: Scaffold(

appBar: AppBar(

title: Text('User List 4Motors'),

),

body: _buildListUser(),

),

);

}

Widget _buildListUser() {

Utility test = new Utility();

print(test.getFirstNameUser());

return ListView.builder(

itemBuilder: (context, position) {

return Card(

child: Padding(

padding: const EdgeInsets.all(16.0),

child: Container(

margin: const EdgeInsets.all(10.0),

child: Row(

crossAxisAlignment: CrossAxisAlignment.start,

children: [

Container(

margin: const EdgeInsets.only(right: 15.0),

child: Image(

width: 65, image: AssetImage('assets/person.jpeg')),  // Image of user

),

Column(

crossAxisAlignment: CrossAxisAlignment.start,

children: [

Text(

'firstname & lastname', // first and last name of user

style: TextStyle(

fontSize: 22,

),

),

Container(

margin: const EdgeInsets.all(5.0),

child: Text('email'), // Email of user

),

],

),

],

),

),

),

);

});

}

}

并且,以下由swagger生成的用户模型:

part of swagger.api;

class UsersData {

String id = null;

String firstName = null;

String lastName = null;

String email = null;

String phone = null;

String image = null;

DateTime birthDay = null;

String fireBaseID = null;

String dealerID = null;

String type = null;

<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值