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

A Flutter package to simplify HTTP requests with support for GET, POST, PUT, PATCH, and DELETE methods. Includes automatic JSON encoding and decoding, and a ResponseModel for handling responses efficiently.

example/example.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Quick Request Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomePage(),
    );
  }
}

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

  @override
  // ignore: library_private_types_in_public_api
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String _responseMessage = 'No data fetched yet';

  @override
  void initState() {
    super.initState();
    _fetchData();
  }

  Future<void> _fetchData() async {
    final apiRequest = QuickRequest();

    try {
      final response = await apiRequest.request(
        url: 'https://jsonplaceholder.typicode.com/posts/1',
        requestMethod: RequestMethod.GET,
      );

      if (!response.error) {
        setState(() {
          _responseMessage = 'Data: ${response.data}';
        });
      } else {
        setState(() {
          _responseMessage = 'Error: ${response.message}';
        });
      }
    } catch (e) {
      setState(() {
        _responseMessage = 'Exception: $e';
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Quick Request Example'),
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Text(
            _responseMessage,
            style: const TextStyle(fontSize: 18),
            textAlign: TextAlign.center,
          ),
        ),
      ),
    );
  }
}
2
likes
0
points
31
downloads

Publisher

verified publisheryeksoftware.com.tr

Weekly Downloads

A Flutter package to simplify HTTP requests with support for GET, POST, PUT, PATCH, and DELETE methods. Includes automatic JSON encoding and decoding, and a ResponseModel for handling responses efficiently.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http

More

Packages that depend on quick_request