a_http 1.0.1 copy "a_http: ^1.0.1" to clipboard
a_http: ^1.0.1 copied to clipboard

Provide flutter developers with a http tool library that supports multi-threaded concurrency

example/lib/main.dart

import 'package:a_http/a_http_lib.dart';
import 'package:autility/autility.dart';
import 'package:autility/utility/a_log.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(App());
}

class App extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'AHttp Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: HomePage(title: 'AHttp Demo'),
    );
  }
}

class HomePage extends StatefulWidget {
  HomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String result;

  @override
  void initState() {
    AHttp.get("https://www.google.com", serializable: StringSerializable())
        .then((value) {
      setState(() {
        result = value;
      });
    }).catchError((error) {
      ALog.info("error", "$error");
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: ListView.builder(
          itemBuilder: (context, index) {
            return Text(result ?? "empty");
          },
          itemCount: 1,
        ),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
1
likes
40
pub points
0%
popularity

Publisher

verified publisheradeveloper.tech

Provide flutter developers with a http tool library that supports multi-threaded concurrency

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

a_thread_pool, autility, convert, crypto, dio, flutter

More

Packages that depend on a_http