minimal_http_client 0.0.3 copy "minimal_http_client: ^0.0.3" to clipboard
minimal_http_client: ^0.0.3 copied to clipboard

A Dart package based on Dio that provides minimal http client to handle HTTP services requests. A minimal http client library for network call

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:minimal_http_client/http_service.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'HTTP Minimal client',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: HomeScreen(httpService: DioHttpService()),
    );
  }
}

class HomeScreen extends StatefulWidget {
  final HttpService httpService;
  const HomeScreen({super.key, required this.httpService});

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  void initState() {
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      final authInterceptor = AuthInterceptor(
        headerCallback: () => {
          'auth_token':
              'Bearer ${DateTime.now().minute}: ${DateTime.now().second}',
          'seassion_key': 'my_seassion_key',
        },
      );
      await DioHttpService().init(authInterceptor: authInterceptor);
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("HTTP Minimal client"),
      ),
      body: Center(
          child: TextButton(
        onPressed: () async {
          final result = await widget.httpService
              .handleGetRequest('https://api.publicapis.org/entries');
          debugPrint("Result: $result");
        },
        child: const Text("Get Info"),
      )),
    );
  }
}
0
likes
160
pub points
0%
popularity

Publisher

unverified uploader

A Dart package based on Dio that provides minimal http client to handle HTTP services requests. A minimal http client library for network call

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dio, dio_http2_adapter, flutter, http, package_info, pretty_dio_logger

More

Packages that depend on minimal_http_client