Home > Software engineering >  app works in androidStudio but not on phone
app works in androidStudio but not on phone

Time:02-17

i have app which gets data from api.

While taking datas from api it waits on loadingScreen.

it works well in androidStudio but when i installed my phone i cant pass loadingScreen

is there any way to that i can pass this screen

texttexttextexttexttexttextexttexttexttextexttexttexttextext

class LoadingScreen extends StatefulWidget {
  String? cityName;

  LoadingScreen(this.cityName) {}
  @override
  _LoadingScreenState createState() => _LoadingScreenState();
}

class _LoadingScreenState extends State<LoadingScreen> {
  Future<void> getWeatherData() async {
    WeatherData weatherData = WeatherData(cityName: widget.cityName);
    await weatherData.getCurrentWeather();
    if (weatherData.currentTemperature == null) {
      print("apiden currenttemeperatu boş gelyio");
    } else {
      Navigator.pushAndRemoveUntil(
          context,
          MaterialPageRoute(
              builder: (context) => MainPage(widget.cityName,
                  weatherData.currentTemperature, weatherData.weatherId)),
          (route) => false);
    }
  }

  void initState() {
    // TODO: implement initState
    super.initState();
    getWeatherData();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        decoration: BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.topLeft,
                end: Alignment.bottomRight,
                colors: [Colors.purple, Colors.blue])),
        child: Directionality(
          textDirection: TextDirection.ltr,
          child: SpinKitChasingDots(
            duration: Duration(milliseconds: 950),
            itemBuilder: (BuildContext context, int index) {
              return DecoratedBox(
                decoration: BoxDecoration(
                  color: index.isEven ? Colors.white : Colors.red,
                  shape: BoxShape.circle,
                ),
              );
            },
          ),
        ),
      ),
    );
  }
}

CodePudding user response:

if (weatherData.currentTemperature == null) {
      print("apiden currenttemeperatu boş gelyio");
    }

Please check your log, i guess your iPhone app don't have network permission.
When iPhone ask you that your iPhone app need network permission, you need to allow that.

CodePudding user response:

Please check that you api endpoint uses https, because http connections are disabled by default.

You can see further info here https://docs.flutter.dev/release/breaking-changes/network-policy-ios-android

  • Related