vessel_bloc 1.0.0 copy "vessel_bloc: ^1.0.0" to clipboard
vessel_bloc: ^1.0.0 copied to clipboard

vessel wrapper for bloc package

example/vessel_bloc_example.dart

import 'package:flutter/material.dart';
import 'package:vessel_flutter/vessel_flutter.dart';

import 'package:vessel_bloc/vessel_bloc.dart';

final counterCubitProvider = BlocProvider<CounterCubit, int>((_) => CounterCubit(0));

class CounterCubit extends Cubit<int> {
  CounterCubit(super.initialState);

  void increment() {
    return emit(state + 1);
  }
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SizedBox.expand(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              counterCubitProvider.builder(
                builder: (context, state) => Text("Count: $state"),
              ),
              SizedBox(height: 10),
              OutlinedButton(
                onPressed: counterCubitProvider.of(context, listen: true).increment,
                child: Text("Increment"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

void main() {
  return runApp(
    ProviderScope(child: App()),
  );
}
0
likes
130
pub points
0%
popularity

Publisher

unverified uploader

vessel wrapper for bloc package

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

bloc, flutter, flutter_bloc, meta, nested, vessel_flutter

More

Packages that depend on vessel_bloc