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

Http clients using Ktor and Alamofire.

example/lib/main.dart

import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';

import 'package:flutter_elo_client/flutter_elo_client.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _response = 'Unknown';
  final _flutterEloClientPlugin = EloClient();

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

    makeRequest(
      const ClientModel(path: 'https://pokeapi.co/api/v2/pokemon/lucario'),
    );
  }

  Future<void> makeRequest(ClientModel params) async {
    String response;

    try {
      response = await _flutterEloClientPlugin.makeRequest(path: params.path) ??
          'Unknown platform version';
    } on PlatformException catch (exception) {
      response = exception.message!;
    }

    if (!mounted) return;

    final lucario = jsonDecode(response) as Map<String, dynamic>;

    setState(() {
      _response = lucario['name'];
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Pokemons'),
        ),
        body: Center(
          child: Text(_response),
        ),
      ),
    );
  }
}
0
likes
140
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

Http clients using Ktor and Alamofire.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_elo_client