restful_api 0.0.2 copy "restful_api: ^0.0.2" to clipboard
restful_api: ^0.0.2 copied to clipboard

A complete REST API client, empowering you to build your app effortlessly without reinventing the wheel. Supports OAuth2, JWT, and token store/refresh using Shared Preferences.

example/lib/main.dart

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

void main() {

  RestfulApiConfig config = RestfulApiConfig();
  config.baseUrl = 'https://smartlib.tijorat.org/api/v1';
  config.usernameField = 'mobile';

  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(

        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

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


  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  RestfulApiConfig config = RestfulApiConfig();

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar( title: const Text("Restful API") ),

      body: const Center(

        child: Text("Salom"),
      ),

      floatingActionButton: FloatingActionButton(
        onPressed: ()async{
          RestfulApi api = RestfulApi();
          Map res = await api.read('books/books');
          debugPrint(res.toString());
        },
        child: const Icon(Icons.login),
      ),

    );
  }
}
0
likes
140
pub points
0%
popularity

Publisher

verified publishertijorat.org

A complete REST API client, empowering you to build your app effortlessly without reinventing the wheel. Supports OAuth2, JWT, and token store/refresh using Shared Preferences.

Homepage

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, http, jwt_decoder, oauth2, shared_preferences

More

Packages that depend on restful_api