Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

flutter its correct on my android studio simulation but on the phone dont works correctly

on my PC my app works correctly, but when i build the APK and i install on my mobile dont works

On my pc i get the title of the API (simulating a android with android studio)

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But when i install the apk on my mobile the screen of de title dont show nothing!

enter image description here

I try on more devices and i get the same error.

void main() => runApp(const HomePage());
class HomePage extends StatelessWidget {
  const HomePage({super.key});
  @override
  Widget build(BuildContext context) {
    const appTitle = 'Youtube MP3';
    return MaterialApp(
      title: appTitle,
      home: Scaffold(
        appBar: AppBar(
          title: const Text(appTitle),
        ),
        body: const FormularioYoutube(),
      ),
    );
  }
}

class FormularioYoutube extends StatelessWidget {
  const FormularioYoutube({super.key});
  @override
  Widget build(BuildContext context) {
    var _controller = TextEditingController();
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
          child: TextFormField(
            controller: _controller,
            decoration: const InputDecoration(
              border: UnderlineInputBorder(),
              labelText: 'Introduzca Url de Youtube',
            ),
          ),
        ),
        MaterialButton(
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(
                  builder: (context) => procesarBotonParaDescargarMp3()),
            );
          },
          color: Colors.blue,
          child: Text('Descargar MP3', style: TextStyle(color: Colors.white)),
        )
      ],
    );
  }
}

class procesarBotonParaDescargarMp3 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Second Route"),
        ),
        body: FutureBuilder<YoutubeMp3?>(
            future: ApiRequest().YoutubeMp3s,
            builder: (context, snapshot) {
              if (snapshot.connectionState == ConnectionState.waiting) {
                return Center(
                  child: CircularProgressIndicator.adaptive(),
                );
              }
              final YoutubeMp3? yt = snapshot.data;
              return ListView.builder(
                  itemCount: 1,
                  itemBuilder: (context, index) {
                    return ListTile(title: Text(yt!.title));
                  });
            }));
  }
}

>Solution :

Check your AndroidManifest. In debug mode Internet Permission is automatically set. It looks like it can’t call the Api Request.

<manifest xmlns:android...>
 ...
 <uses-permission android:name="android.permission.INTERNET" />
 <application ...
</manifest>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading