// ignore_for_file: must_call_super, prefer_typing_uninitialized_variables, no_logic_in_create_state import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:namer_app/footer.dart'; import 'package:namer_app/header.dart'; import 'package:namer_app/service/delete_member.dart'; import '../globals.dart'; class ListMemberPage extends StatefulWidget { final int projId; const ListMemberPage({super.key, required this.projId}); @override State createState() => _ListMemberPageState( bugId: projId ); } class _ListMemberPageState extends State { int bugId; _ListMemberPageState({required this.bugId}); var members; @override void initState(){ getData(bugId); } void getData(int bugId) async { try { var response = await Dio() .get('http://localhost:8080/api/v1/projects/$bugId/member', options: Options(headers: headers)); if (response.statusCode == 200) { setState(() { members = response.data['results'] as List; }); } else { print(response.statusCode); } } catch (e) { print(e); } } @override Widget build(BuildContext context) { return Scaffold( appBar: CustomAppbar(), body: Stack(children: [ SingleChildScrollView( child: Column( children: [ Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'LIST MEMBER', style: TextStyle(color: Colors.black, fontSize: 48), ), ], )), Column( children: List.generate( members == null ? 0 : members.length, (i) => SizedBox( child: ListTile( leading: SizedBox( child: Icon(Icons.group_work), ), title: Text(members[i]['project']), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text(members[i]['user']), Expanded(child: Container()), Text(members[i]['role']) ], ), ], ), trailing: ButtonUser( items: members[i], ), ), )), ), ], ), ), ]), bottomNavigationBar: Footer(), ); } } class ButtonUser extends StatelessWidget { final Map items; ButtonUser({ required this.items, super.key, }); //todo delete //todo tombol item @override Widget build(BuildContext context) { return Row( // crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ ElevatedButton( onPressed: () => delmember(context, items['id']), style: ElevatedButton.styleFrom( backgroundColor: Colors.black, ), child: Text( 'Delete', style: TextStyle(color: Colors.white), ), ), ], ); } }