request_api_helper 3.0.2+1 copy "request_api_helper: ^3.0.2+1" to clipboard
request_api_helper: ^3.0.2+1 copied to clipboard

outdated

integrating API will be faster and doesn't take long, just configure the initial settings and you can use this helper freely.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:request_api_helper/request.dart' as req;
import 'package:request_api_helper/request_api_helper.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  final List<ServerSwitcherData> _servers = [
    ServerSwitcherData(linkServer: 'https://official-joke-api.appspot.com/', nameServer: 'Jokes Api'),
  ];

  _sendRequest() async {
    req.send(
      type: RESTAPI.post,
      context: context,
      name: 'jokes/programming/random',
      data: RequestData(),
      changeConfig: RequestApiHelperConfigData(
        logResponse: true,
        withLoading: Redirects(toogle: true),
      ),
    );
  }

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            SizedBox(
              child: Material(
                borderRadius: const BorderRadius.all(Radius.circular(12)),
                color: Colors.blue,
                child: InkWell(
                  child: const Padding(
                    padding: EdgeInsets.symmetric(vertical: 14),
                    child: Center(
                      child: Text(
                        'Check Error Auth Redirect (Error Harus 404)',
                        style: TextStyle(color: Colors.white),
                      ),
                    ),
                  ),
                  onTap: () async {
                    await _sendRequest();
                  },
                ),
              ),
            ),
          ],
        ),
      ),
      bottomNavigationBar: SizedBox(
        height: 50,
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
          child: Row(
            children: [
              SizedBox(
                child: Center(
                    child: ServerSwitcher(
                  saved: true,
                  servers: _servers,
                )),
              ),
              const Text('Select Server Here'),
            ],
          ),
        ),
      ),
    );
  }
}
6
likes
0
pub points
26%
popularity

Publisher

unverified uploader

integrating API will be faster and doesn't take long, just configure the initial settings and you can use this helper freely.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, fluttertoast, http, http_parser, shared_preferences

More

Packages that depend on request_api_helper