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)
But when i install the apk on my mobile the screen of de title dont show nothing!
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));
});
}));
}
}
CodePudding user response:
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>