import 'package:flutter/material.dart'; void main() { runApp(const MaterialApp(home: Messenger())); } class Messenger extends StatefulWidget { const Messenger({super.key}); @override State<Messenger> createState() => _MessengerState(); } class _MessengerState extends State<Messenger> { List<UserProf> activeUsers = [ UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), ]; List<UserProf> users = [ UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), UserProf("Babe", "assets/wallpaper.jpg"), UserProf("Hung", "assets/junimo.png"), UserProf("Babe", "assets/lake.jpg"), ]; @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( appBar: AppBar( actions: [ TextButton( onPressed: () { Navigator.pop(context); }, child: const Icon(Icons.logout)) ], centerTitle: true, backgroundColor: Colors.purple[200], title: const Text("Messenger"), ), body: Column( children: [ const Padding( padding: EdgeInsets.only(left: 15, right: 15, top: 15), child: TextField( decoration: InputDecoration( prefixIcon: Icon(Icons.search), border: OutlineInputBorder( borderSide: BorderSide( color: Colors.purple, )), ), ), ), Container( height: 100, // Set a fixed height here width: MediaQuery.of(context).size.width, child: ListView( scrollDirection: Axis.horizontal, children: activeUsers .map( (e) => Container( margin: const EdgeInsets.all(8), child: Column( children: [ CircleAvatar( radius: 30, backgroundImage: AssetImage(e.avtUrl), ), Text(e.userName), ], ), ), ) .toList(), ), ), Expanded( child: ListView( children: users .map((e) => ListTile( leading: CircleAvatar( backgroundImage: AssetImage(e.avtUrl)), title: Text(e.userName), subtitle: const Text( 'Chào em anh đứng đây từ chiều', style: TextStyle(fontFamily: 'Righteus'), ), )) .toList(), ), ), ], ), floatingActionButton: FloatingActionButton( onPressed: () { setState(() { if (users.isNotEmpty) { users.removeAt(users.length - 1); } }); }, child: const Icon(Icons.remove_circle_sharp), ), bottomNavigationBar: BottomNavigationBar(items: const [ BottomNavigationBarItem(icon: Icon(Icons.chat), label: 'Chats'), BottomNavigationBarItem( icon: Icon(Icons.api_rounded), label: 'Story'), ]), ), ); } } class UserProf { final String userName; final String avtUrl; UserProf(this.userName, this.avtUrl); }