fluent_networking 0.0.4 copy "fluent_networking: ^0.0.4" to clipboard
fluent_networking: ^0.0.4 copied to clipboard

Package that provides a simple way to make http requests

fluent_networking #

Package that provides a simple way to make http requests

Getting Started #

Add dependencies #

fluent_networking: ^0.0.4

Create networking config #

class ApiConfig extends NetworkingConfig {
  @override
  String get baseUrl => "https://pokeapi.co/api/v2";
}

Build module #

void main() async {
  await Fluent.build([
    NetworkingModule(config: ApiConfig()),
  ]);

  runApp(const MainApp());
}

Use it #

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

  @override
  Widget build(BuildContext context) {
    // Get networking api
    final networkingApi = Fluent.get<NetworkingApi>();
    // Make get request
    final future = networkingApi.get<Map<String, dynamic>>("/pokemon");

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text("Fluent Networking Demo"),
        ),
        body: FutureBuilder(
          future: future,
          builder: (context, snapshot) {
            return snapshot.data?.when(
                  succeeded: (data) {
                    final results = data["results"];
                    return ListView.builder(
                      itemCount: results.length,
                      itemBuilder: (context, index) {
                        return ListTile(
                          leading: Text(results[index]["name"]),
                          title: Text(results[index]["url"]),
                        );
                      },
                    );
                  },
                  failed: (data) => const Text("Failed error"),
                  error: (error) => Text(error.message ?? ""),
                ) ??
                const Center(
                  child: CircularProgressIndicator(),
                );
          },
        ),
      ),
    );
  }
}

Example #

0
likes
120
pub points
0%
popularity

Publisher

unverified uploader

Package that provides a simple way to make http requests

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

dio, equatable, fluent_networking_api, fluent_sdk, freezed_annotation, pretty_dio_logger

More

Packages that depend on fluent_networking