This is the complete code,
class Authorize extends StatefulWidget {
const Authorize({super.key});
@override
State<Authorize> createState() => _AuthorizeState();
}
class _AuthorizeState extends State<Authorize> {
late Future<List<dynamic>> _custList;
@override
void initState() {
super.initState();
//_futureList = fetchListData();
_custList = ModelsPositions().getCust();
}
_launchURL(String url) async {
final uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri, mode: LaunchMode.externalApplication);
} else {
throw 'Could not launch $url';
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('sample orders'),
),
//automaticallyImplyLeading: false),
body: FutureBuilder<List<dynamic>>(
future: _custList,
builder: (context, snapshot) {
if (snapshot.hasData) {
List<dynamic> custAPIs = snapshot.data ?? [];
return ListView.builder(
itemCount: custAPIs.length,
itemBuilder: (context, index) {
String custID = custAPIs[index][0];
return Card(
child: Row(
children: [
SizedBox(width: 50),
Expanded(
child: Text('custID: $custID'),
),
SizedBox(width: 15),
Expanded(
child: ElevatedButton(
child: const Text('check'),
onPressed: () {
String url =
"https://www.amazon.in/";
_launchURL(url);
}),
),
],
),
);
});
} else if (snapshot.hasError) {
return const Center(
child: Text('Failed to fetch Positions Summary'));
}
return const Center(child: CircularProgressIndicator());
},
));
}
}
I'm installed apk file in mobile and trying to open from mobile.(When I tried in emulator working fine but after generating apk and installing in mobile it is not opening the webpage).