I am trying to achieve this:

But as I m new to this don't understand how to implement. I check many code but nothing help me so please help me. I am beginner in the coding.
In this code I use json file and I am able to display list tile but as shown in the image I want to add some text and icon below this list tile but when I add any widget it goes side to leading
I don't understand how do I do this
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
List _items = [];
// Fetch content from the json file
Future<void> readJson() async {
final String response = await rootBundle.loadString('assets/sample.json');
final data = await json.decode(response);
setState(() {
_items = data["items"];
});
}
@override
void initState() {
super.initState();
// Call the readJson method when the app starts
readJson();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: Colors.white,
centerTitle: true,
elevation: 0,
title: const Text(
'Ask Help',
style: TextStyle(color: Colors.black),
),
),
body: Padding(
padding: const EdgeInsets.fromLTRB(12, 0, 12, 0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
children: <Widget>[
ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
//change width and height on your need width = 200 and height = 50
minimumSize: Size(160, 50),
),
child: const Text('Patient'),
)
],
),
Column(
children: <Widget>[
OutlinedButton(
style: OutlinedButton.styleFrom(
side: const BorderSide(color: Colors.blue, width: 1),
minimumSize: Size(160, 50)),
onPressed: () {},
child: const Text(
"NGO",
style: TextStyle(color: Colors.blue),
),
),
],
)
],
),
// Display the data loaded from sample.json
Container(
child: _items.isNotEmpty
? Expanded(
child: ListView.separated(
itemCount: _items.length,
separatorBuilder: (BuildContext context, int index) =>
Divider(height: 1),
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ListTile(
leading: CircleAvatar(
child:
Text(_items[index]["imageUrl"].toString()),
),
title: Text(_items[index]["name"]),
subtitle: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(_items[index]["phone_number"],
style: const TextStyle(
fontSize: 13.0,
fontWeight: FontWeight.normal)),
Text(_items[index]["email_id"],
style: const TextStyle(
fontSize: 13.0,
fontWeight: FontWeight.normal)),
// Text(
// 'Population: ${_items[index]["email_id"]}',
// style: const TextStyle(
// fontSize: 11.0,
// fontWeight: FontWeight.normal),
// ),
]
),
trailing: const Icon(Icons.more_vert),
),
);
},
),
)
: Container(
//color: Colors.amber,
),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 70,
child: Center(
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
//change width and height on your need width = 200 and height = 50
minimumSize: Size(300, 50),
),
child: const Text('Register'),
),
),
),
)
],
),
),
);
}
}
My json code:
{
"items": [
{
"id": "p1",
"name": "Item 1",
"phone_number":"8975412369",
"email_id":"[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p2",
"name": "Item 2",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p3",
"name": "Item 3",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p1",
"name": "Item 1",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p2",
"name": "Item 2",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p3",
"name": "Item 3",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p1",
"name": "Item 1",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p2",
"name": "Item 2",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p3",
"name": "Item 3",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},{
"id": "p1",
"name": "Item 1",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p2",
"name": "Item 2",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
},
{
"id": "p3",
"name": "Item 3",
"phone_number": "8975412369",
"email_id": "[email protected]",
"description": "Description 1",
"imageUrl": "https://m.media-amazon.com/images/I/81S-ekaE+vS._AC_UL320_.jpg"
}
]
}
The answer to the question is yes! Here's a minimal example:
The above class goes in
data_model.dartfile. I have made a data model for you. Before working on UI, it's best to organize your code into different parts.There is also this custom widget made for easier handling of stuff and the DRY rule! This goes to the
details.dartfile.Edited main.dart:
I have modified the UI code to represent the model changes.
Your code and JSON sample are a bit far from the linked image you want to implement, but I have used made-up details to represent a better example to you. Feel free to play with the code and UI.