0

i'm new to Flutter here, i'm not sure whether this is related to question has been posted to this forum, so i'm trying to load image from firebase storage, i have got the urls fine and when i print out in the system and click the url, i can see the image, but i'm not sure why when trying on my device or my laptop the image does not load, but when i hit ctrl + s / hot reload on the code, the image is loaded.

here is few thing i have done:

  1. Make sure added Internet to android-manifest.xml
  2. disable proxy connection on my laptop

what am i using when running the code : 1. Windows OS 2. OPPO F1s 3. Nexus 5x API R (AVD Manager)

Also i have pinged google from adb shell (connect to my oppo devices) it works as well.

I'm not sure why need to hot reload just to load the image properly, is there any solution regarding this issue?

Below is how's my code look like:

    import 'package:flutter/material.dart';
import 'package:flutter_app/models/app_state.dart';
import 'package:flutter_app/models/produk.dart';
import 'package:flutter_app/pages/halaman_produk_detail.dart';
import 'package:flutter_app/redux/actions.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:transparent_image/transparent_image.dart';

class ProdukItems extends StatelessWidget{
  final dynamic item;

  ProdukItems({this.item});

  bool _isInCart(AppState state, String id){
      final List<Produk> listProduk =  state.keranjangBelanja;
      return listProduk.indexWhere((produk) => produk.id == id) > -1;
  }

  @override
  Widget build(BuildContext context) {
    final String pictureUrl = item.gambarProdukFirebaseDB;
    return InkWell(
      onTap: () => Navigator.of(context).push(
        MaterialPageRoute(
          builder: (context){
            return HalamanProdukDetail(item: item);
          }
        )
      ),
      child:
      GridTile(
      child: Hero(
        tag: item,
        child: FadeInImage.memoryNetwork(placeholder: kTransparentImage, image: pictureUrl, fit: BoxFit.cover,)),
      footer: GridTileBar(
        title: FittedBox(
          fit: BoxFit.scaleDown,
          alignment: Alignment.centerLeft,
          child: Text(item.namaProduk, style: TextStyle(fontSize: 20.0),),
        ),
        subtitle: Text("Rp. ${item.hargaProduk}",style: TextStyle(fontSize: 16.0),),
        backgroundColor: Colors.black38,
        trailing: StoreConnector<AppState, AppState>(
          converter: (store) => store.state,
          builder: (_, state){
            return state.user != null ?
            IconButton(
              icon: Icon(Icons.shopping_cart), color: _isInCart(state, item.id) == true ? Colors.blue[400] : Colors.white ,
            onPressed: ()=> {
              StoreProvider.of<AppState>(context).dispatch(pencetKeranjangProdukAction(item))
            },) : Text('');
          },
        ),
      ),
    ),);
  }
}

Thank you in advance.

LeonGint
  • 1
  • 3

0 Answers0