London Escorts sunderland escorts 1v1.lol unblocked yohoho 76 https://www.symbaloo.com/mix/yohoho?lang=EN yohoho https://www.symbaloo.com/mix/agariounblockedpvp https://yohoho-io.app/ https://www.symbaloo.com/mix/agariounblockedschool1?lang=EN
3.1 C
New York
Wednesday, December 4, 2024

android – Fetching the Api Information collectively


I get this drawback in my house display screen fetching a number of Api in identical display screen having drawback is that when display screen hundreds then first it calls banner Api after which after 2 seconds it calls the Gridview Information from scrolling high of the display screen like slightly animation so I do not need this to occur I easy need all Api fetch collectively not one after one. So can anybody assist me on this please?
That is my Api calls:

  Future<Record<BannerItem>> fetchbanner() async{
  last response = await http.get(Uri.parse('${AppColors.api}/app/banners'));
  if(response.statusCode == 200){
    last Map<String, dynamic> responseMap = json.decode(response.physique);
    last Map<String, dynamic> dataMap = responseMap['data'];
    last Record<dynamic> bannerData = dataMap['results'];
    return bannerData.map((json) => BannerItem.fromJson(json)).toList();

  } else {
    throw Exception('Did not load banners');
  }
}

  Future<Record<Product>> fetchProducts() async {
  last response = await http.get(Uri.parse('${AppColors.api}/merchandise'));
  if (response.statusCode == 200) {
    last Map<String, dynamic> responseMap = json.decode(response.physique);
    last Map<String, dynamic> dataMap = responseMap['data'];
    last Record<dynamic> productList = dataMap['results'];
    SharedPreferences prefs = await SharedPreferences.getInstance();
    Record<String> productIds = productList.map((json) => Product.fromJson(json).id).toList();
    await prefs.setStringList('productIds', productIds);
    return productList.map((json) => Product.fromJson(json)).toList();
  } else {
    throw Exception('Did not load merchandise');
  }
}
 FutureBuilder<Record<BannerItem>>(
                  future: _futureBanners,
                  builder: (context, snapshot){
                    if(snapshot.connectionState == ConnectionState.ready){
                      return Heart(baby: CircularProgressIndicator(shade: AppColors.buttonColor,),);
                    } else if (snapshot.hasError) {
                       return Heart(baby: Textual content('Error: ${snapshot.error}'));
                      }else if (!snapshot.hasData || snapshot.knowledge!.isEmpty) {
                        return const Heart(baby: Textual content('No merchandise out there'));
                       } else {
                        last banners = snapshot.knowledge!;  
                  return AnimatedSize(
                    length: const Period(milliseconds: 300),
                    baby: Container(
                      width: double.infinity,
                      ornament: BoxDecoration(
                        shade: AppColors.backgroundColor,
                        borderRadius: BorderRadius.round(0),
                      ),
                      baby: Padding(
                        padding: const EdgeInsets.solely(high: 10.0),
                        baby: Column(
                          crossAxisAlignment: CrossAxisAlignment.begin,
                          kids: [
                          Container(
  width: double.infinity,
  height: MediaQuery.of(context).size.height * 0.2,
  decoration: BoxDecoration(
    borderRadius: BorderRadius.circular(30),
    color: const Color.fromARGB(255, 249, 255, 249),
  ),
  child: PageView.builder(
    controller: _pageController,
    onPageChanged: (index) {
      setState(() {
        _currentPage = index;
      });
    },
    itemCount: banners.length,
    itemBuilder: (context, index) {
      return GestureDetector(
        
        onTap: () async {
              final url = Uri.parse(banners[index].url);
           if (await canLaunchUrl(url)) {
            await launchUrl(url, mode: LaunchMode.externalApplication);
          } else {
            ScaffoldMessenger.of(context).showSnackBar(
              SnackBar(content material: Textual content('Couldn't launch $url')),
            );
          }
        },
        baby: Container(
          margin: const EdgeInsets.symmetric(horizontal: 10.0),
          ornament: BoxDecoration(
            borderRadius: BorderRadius.round(30),
            shade: AppColors.lightTheme,
          ),
          clipBehavior: Clip.hardEdge, 
          baby: Picture.community(
            banners[index].picture,
            match: BoxFit.cowl,
            width: double.infinity,
            peak: double.infinity, 
            
          ),
        ),
      );
    },
  ),
),
const SizedBox(peak: 10),
Row(
  mainAxisAlignment: MainAxisAlignment.middle,
  kids: Record.generate(banners.size, (index) {
    return Container(
      margin: const EdgeInsets.symmetric(horizontal: 4),
      width: 10,
      peak: 10,
      ornament: BoxDecoration(
        form: BoxShape.circle,
        shade: _currentPage == index
            ? AppColors.buttonColor
            : Colours.inexperienced.shade200,
      ),
    );
  }),
),

GRIDVIEW API

  FutureBuilder<Record<Product>>(
                          future: _futureProducts,
                          builder: (context, snapshot) {
                            if (snapshot.connectionState == ConnectionState.ready) {
                              return const Heart(baby: CircularProgressIndicator(
                                shade: AppColors.buttonColor,
                              ));
                            } else if (snapshot.hasError) {
                              return Heart(baby: Textual content('Error: ${snapshot.error}'));
                            } else if (!snapshot.hasData || snapshot.knowledge!.isEmpty) {
                              return const Heart(baby: Textual content('No merchandise out there'));
                            } else {
                              last merchandise = snapshot.knowledge!;
                              return Padding(
                                padding: const EdgeInsets.all(8.0),
                                baby: GridView.builder(
                                 controller: _gridScrollController, 
                  shrinkWrap: true,
                  physics: const NeverScrollableScrollPhysics(),
                  gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2,
                    crossAxisSpacing: 10.0,
                    mainAxisSpacing: 10.0,
                    childAspectRatio: 0.99,
                  ),
                  itemCount: merchandise.size,
                  itemBuilder: (context, index) {
                    last product = merchandise[index];
                    last isFavorite = favoriteProvider.isFavorite(product);
                  
                    return GestureDetector(
                      onTap: () {
                        Navigator.push(
                          context,
                          MaterialPageRoute(
                            builder: (context) => ItemDetailsScreen(productId: product.id),
                          ),
                        );
                      },
                      baby: Card(
                        shade: Colours.white,
                        elevation: 5,
                        form: RoundedRectangleBorder(
                          borderRadius: BorderRadius.round(15),
                        ),
                        baby: Container(
                          ornament: BoxDecoration(
                            borderRadius: BorderRadius.round(20),
                            border: Border.all(
                              shade: Colours.white,
                              width: 5,
                            ),
                          ),
                          baby: Stack(
                            kids: [
                              Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Flexible(
                                    flex: 2,
                                    child: ClipRRect(
                                      borderRadius: const BorderRadius.vertical(top: Radius.circular(15)),
                                      child: Container(
                                        color: AppColors.lightTheme,
                                        child: Image.network(
                                          product.imageUrl,
                                          fit: BoxFit.cover,
                                          width: double.infinity,
                                        ),
                                      ),
                                    ),
                                  ),
                                  Padding(
                                    padding: const EdgeInsets.all(8.0),
                                    child: Column(
                                      crossAxisAlignment: CrossAxisAlignment.start,
                                      children: [
                                        Text(
                                          product.title,
                                          style: const TextStyle(
                                            fontSize: 16,
                                            fontWeight: FontWeight.bold,
                                          ),
                                        ),
                                        Text(
                                          '₹${product.marketPrice}',style:TextStyle(
                                                  fontSize: 16,
                                                  fontWeight: FontWeight.bold,
                                                  color: AppColors.priceColor,
                                                ) ,
                                        )
                                       
                                      ],
                                    ),
                                  ),
                                ],
                              ),

Related Articles

Social Media Auto Publish Powered By : XYZScripts.com