folivora_http 0.0.1 copy "folivora_http: ^0.0.1" to clipboard
folivora_http: ^0.0.1 copied to clipboard

outdated

A useful http package.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:folivora_http/folivora_http.dart';
import 'package:twostrings_palette/twostrings_palette.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Two Strings Package Test App',
      theme: ThemeData(
        primarySwatch:
            MaterialColor(TwoStringsColor.primaryMaterialColor.colorHex, TwoStringsColor.primaryMaterialColor.swatch),
      ),
      home: const MyHomePage(title: 'Two Strings Home Page'),
    );
  }
}

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"),
        ),
      ),
    );
  }
}