webservice 0.0.5 webservice: ^0.0.5 copied to clipboard
A powerful Http client for Dart, which handles requests. Super easy to use and much more comming soon. Wait for our updates.
import 'package:flutter/material.dart';
import 'package:webservice/webservice.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'WebService',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
getData();
super.initState();
}
getData(){
WebService().get(url: "https://dummyjson.com/products", onResponse: (response){
if(response.statusCode==200){
//print response Data
print(response.data);
}else{
//print error message on fail
print(response.message);
}
});
}
@override
Widget build(BuildContext context) {
return const Scaffold();
}
}