easy_http 2.0.13 copy "easy_http: ^2.0.13" to clipboard
easy_http: ^2.0.13 copied to clipboard

A Flutter Http lib for easy cache and update UI bind with Getx.

example/lib/main.dart

import 'dart:developer';

import 'package:easy_http/config/default_easy_http_config.dart';
import 'package:easy_http/easy_http.dart';
import 'package:example/generated/json/base/json_convert_content.dart';
import 'package:example/ui/test_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

void main() async {
  await EasyHttp.init(config: DefaultEasyHttpConfig(JsonConvert.fromJsonAsT));
  EasyHttp.addInterceptor(InterceptorsWrapper(onError: (
    DioException e,
    ErrorInterceptorHandler handler,
  ) {
    handler.next(e);
  }, onRequest: (RequestOptions options, RequestInterceptorHandler handler) {
    log("send request ${options.uri}");
    return handler.next(options);
  }, onResponse: (Response e, ResponseInterceptorHandler handler) {
    return handler.next(e);
  }));
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      localizationsDelegates: const [
        RefreshLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: const [
        Locale('en'), // American English
        Locale('zh'), // Israeli Hebrew
        // ...
      ],
      title: 'EasyHttp',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const TestPage(),
    );
  }
}
2
likes
130
pub points
45%
popularity

Publisher

unverified uploader

A Flutter Http lib for easy cache and update UI bind with Getx.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dio, flutter, get, get_storage, pull_to_refresh

More

Packages that depend on easy_http