Here is my api data structure. Using this api, I have fetched data.
The source code is here. Now I want to show data(e.g. pROJTNAME) in a drop down list and user can select the list like the image below. How this can be achieved?
Here is main.dart
import 'package:flutter/material.dart'; import 'package:get_api/model.dart'; import 'package:get_api/services.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: JsonParseDemo(), ); } } class JsonParseDemo extends StatelessWidget { /* ---------------------------------------------------------------------------- */ const JsonParseDemo({Key key}) : super(key: key); /* ---------------------------------------------------------------------------- */ @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Hi!'), centerTitle: true, ), body: FutureBuilder<User>( future: NetService.fetchTickesInfo(), builder: (context, snapshot) => snapshot.hasData ? ListView.builder( itemCount: snapshot.data.projectInfos.length, itemBuilder: (context, index) => Card( child: Column( children: [ Text(snapshot.data.projectInfos[index]?.pROJTNAME ?? '--'), Text(snapshot.data.projectInfos[index]?.pROJTDESC ?? '--'), ], ), ), ) : snapshot.hasError ? Text('Something was wrong!: ${snapshot.error}') : Center( child: CircularProgressIndicator(), )), ); } } https://stackoverflow.com/questions/65568566/how-to-show-data-in-drop-down-list-using-rest-api-in-flutter January 05, 2021 at 03:22AM

没有评论:
发表评论