fluent_networking 0.0.2+1 copy "fluent_networking: ^0.0.2+1" to clipboard
fluent_networking: ^0.0.2+1 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.2+1

Create networking config #

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

Build module #

Fluent.build([
    NetworkingModule(),
]);

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
0
pub points
42%
popularity

Publisher

unverified uploader

Package that provides a simple way to make http requests

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

dio, equatable, fluent_networking_api, flutter_loggy_dio, freezed_annotation

More

Packages that depend on fluent_networking