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

This is a simplified implementation of Dio it helps quickly have dio implementation in their projects.

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:dio_client_extended/dio_client_extended.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool valueGet = false;

  @override
  void initState() {
    super.initState();
    Future.delayed(Duration.zero, () {
      getPosts();
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text(
              'Running on: $valueGet\n'),
        ),
      ),
    );
  }

  getPosts() async {
    ///[DioClientExtended] object instantiation
    final dioClient =
        DioClientExtended(baseUrl: 'https://jsonplaceholder.typicode.com');
    try {
      ///calling of the methods

      final response = await dioClient.get(path: '/posts');
      if (response.statusCode == 200) {
        debugPrint(jsonEncode(response.data));
        setState(() {
          valueGet = true;
        });
      } else {
        debugPrint(response.statusMessage);
      }
    } on Exception catch (e) {
      debugPrint('Error: $e');
    }
  }
}
1
likes
140
points
18
downloads

Publisher

unverified uploader

Weekly Downloads

This is a simplified implementation of Dio it helps quickly have dio implementation in their projects.

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

dio, flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on dio_client_extended