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

An HTTP module derived from Dio is designed to handle refresh tokens in JWT.

example/lib/main.dart

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

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

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

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'text_home',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineLarge,
            ),
          ],
        ),
      ),
      floatingActionButton: Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: [
          const SizedBox(
            width: 20,
          ),
          FloatingActionButton(
            onPressed: () async {
              String baseApi = "https://rickandmortyapi.com/api";

              final dio = Dio(
                BaseOptions(
                  baseUrl: baseApi,
                  validateStatus: (value) {
                    return value! < 500;
                  },
                ),
              );
              var service = RestService(
                  dioClient: dio,
                  expiredToken: (Response<dynamic> response,
                      ResponseInterceptorHandler handler) async {});
              await service.get(endpoint: "");
            },
            tooltip: 'Test Api Client',
            child: const Text("Api"),
          ),
          const Spacer(),
          FloatingActionButton(
            onPressed: _incrementCounter,
            tooltip: 'Increment',
            child: const Icon(Icons.add),
          ),
        ],
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
0
likes
140
pub points
0%
popularity

Publisher

unverified uploader

An HTTP module derived from Dio is designed to handle refresh tokens in JWT.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dio, flutter

More

Packages that depend on wat_dio