import 'package:flutter/material.dart'; import 'package:generp/Notifiers/PaymentCollectionProvider.dart'; import 'package:generp/Utils/app_colors.dart'; import 'package:generp/Utils/commonWidgets.dart'; import 'package:generp/screens/serviceEngineer/PaymentDetails.dart'; import 'package:provider/provider.dart'; class Accountsuggestions extends StatefulWidget { const Accountsuggestions({super.key}); @override State createState() => _AccountsuggestionsState(); } class _AccountsuggestionsState extends State { final TextEditingController _searchController = TextEditingController(); @override Widget build(BuildContext context) { return Consumer( builder: (context,provider,child) { return Scaffold( appBar: appbar(context, "Accounts"), backgroundColor: AppColors.scaffold_bg_color, body: Column( children: [ const SizedBox( height: 10, ), Container( alignment: Alignment.center, height: 55, margin: EdgeInsets.only(left: 15.0, right: 15.0), child: TextField( controller: _searchController, keyboardType: TextInputType.text, onChanged: (value) { if (value.length >= 3) { provider.AccountSuggestionAPI(context, value); } }, decoration: InputDecoration( hintText: "Enter Account Name.....", hintStyle: TextStyle( fontWeight: FontWeight.w400), filled: true, ), ), ), Container( margin: EdgeInsets.only(top: 5.0, left: 25.0), alignment: Alignment.topLeft, child: Text( "Note: Enter Minimum 3 Characters", style: TextStyle( fontWeight: FontWeight.w300, ), ), ), Expanded( child: SingleChildScrollView( physics: AlwaysScrollableScrollPhysics(), child: Container( child: GridView.builder( itemCount: provider.accountList!.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 1, // 4 items in a row for tablet crossAxisSpacing: 4, mainAxisSpacing: 2, childAspectRatio: (100 / 25)), padding: const EdgeInsets.all(5), physics: const BouncingScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) { var accountList = provider.accountList; if (accountList!.length > 0) { return InkWell( onTap: () { // if(actname == "pendingComplaints"&&status=="Open"){ Navigator.push( context, MaterialPageRoute( builder: (context) => Paymentdetails( accountName: "Account", name: accountList![index].accountName, genId: "", referenceID: accountList![index].accountId, ), )); // } }, child: SizedBox( child: Container( width: MediaQuery.of(context).size.width * 0.9, padding: EdgeInsets.fromLTRB(0, 5, 0, 5), child: Text( "${accountList![index].accountName}", textAlign: TextAlign.start, maxLines: 3, overflow: TextOverflow.ellipsis, style: TextStyle( fontWeight: FontWeight.w300, ), ), ), ), ); } else { return Expanded( child: SingleChildScrollView( physics: AlwaysScrollableScrollPhysics(), child: Container( width: double.infinity, height: MediaQuery.of(context) .size .height, // Set width to fill parent width decoration: BoxDecoration( borderRadius: BorderRadius.only( topLeft: Radius.circular(30.0), topRight: Radius.circular(30.0), ), ), padding: EdgeInsets.fromLTRB(10, 10, 10, 10), child: Container( child: Align( alignment: Alignment.center, child: Text( "No Data Available", style: TextStyle( fontWeight: FontWeight.bold, overflow: TextOverflow.ellipsis, ), )), )), )); } }), ), )) ], ), ); } ); } }