folivora_http 0.0.2
folivora_http: ^0.0.2 copied to clipboard
A useful http package.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:folivora_http/folivora_http.dart';
import 'theme_notifier.dart';
void main() {
runApp(ThemeNotifier(child: const MyApp()));
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ValueListenableBuilder(
valueListenable: ThemeNotifier.of(context)!.theme,
builder: (BuildContext context, ThemeData themeData, child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Folivora Package Test App',
theme: themeData,
home: const MyHomePage(title: 'Folivora'),
);
},
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: ElevatedButton(
onPressed: () async {
FvHttp.init(scheme: "https", host: 'api.agify.io');
await FvHttpClient.get(
path: '', queryParameters: {"name": "dhkim"});
FvHttp.init(
scheme: "https",
host: 'api.agify.io',
jsonDecodingOption: JsonDecodingOption.noOption);
await FvHttpClient.external(
uriAddress: 'https://api.agify.io?name=dhkim', method: "GET");
FvHttp.init(
scheme: "https",
host: 'api.agify.io',
jsonDecodingOption: JsonDecodingOption.utf8);
await FvHttpClient.external(
uriAddress: 'https://api.agify.io?name=dhkim', method: "GET");
FvHttp.init(scheme: "https", host: 'httpbin.org');
await FvHttpClient.get(path: 'get');
await FvHttpClient.post(path: 'post', body: {});
await FvHttpClient.put(path: 'put', body: {});
await FvHttpClient.delete(path: 'delete', body: {});
await FvHttpClient.patch(path: 'patch', body: {});
},
child: const Text("Test"),
),
),
);
}
}