api_bloc 1.9.2 copy "api_bloc: ^1.9.2" to clipboard
api_bloc: ^1.9.2 copied to clipboard

Significantly reducing boilerplate code of BLoC pattern to efficiently handle API interactions.

example/lib/main.dart

import 'package:example/fetch/get_page.dart';
import 'package:example/submit/post_page.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(home: HomePage()));
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("API Bloc"),
        ),
        body: Column(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.center,
            children: List.generate(
                2,
                (x) => Padding(
                    padding: const EdgeInsets.all(10.0),
                    child: Center(
                        child: ColoredBox(
                            color: Colors.blue,
                            child: TextButton(
                                onPressed: () {
                                  Navigator.push(
                                      context,
                                      MaterialPageRoute(
                                          builder: (context) => [
                                                GetPage(),
                                                const PostPage()
                                              ][x]));
                                },
                                child: Text(
                                    ["Fetch Sample", "Submit Sample"][x],
                                    textAlign: TextAlign.center,
                                    style: const TextStyle(
                                        color: Colors.white)))))))));
  }
}

void snackbar(BuildContext context,
        {required String message, Color color = Colors.green}) =>
    ScaffoldMessenger.of(context)
        .showSnackBar(SnackBar(content: Text(message), backgroundColor: color));
9
likes
0
pub points
30%
popularity

Publisher

verified publisherinidia.app

Significantly reducing boilerplate code of BLoC pattern to efficiently handle API interactions.

Homepage
Repository (GitHub)
View/report issues

Topics

#bloc #api

Funding

Consider supporting this project:

ko-fi.com

License

unknown (license)

Dependencies

args, flutter

More

Packages that depend on api_bloc