Back to Bloc

README

extensions/vscode/README.md

latest7.6 KB
Original Source
<p align="center"> </p> <p align="center"> <a href="https://github.com/felangel/bloc/actions"></a> <a href="https://codecov.io/gh/felangel/bloc"></a> <a href="https://github.com/felangel/bloc"></a> </p> <p align="center"> <a href="https://marketplace.visualstudio.com/items?itemName=FelixAngelov.bloc"></a> <a href="https://marketplace.visualstudio.com/items?itemName=FelixAngelov.bloc"></a> <a href="https://marketplace.visualstudio.com/items?itemName=FelixAngelov.bloc"></a> <a href="https://marketplace.visualstudio.com/items?itemName=FelixAngelov.bloc"></a> <a href="https://flutter.dev/docs/development/data-and-backend/state-mgmt/options#bloc--rx"></a> <a href="https://github.com/Solido/awesome-flutter#standard"></a> <a href="http://fluttersamples.com"></a> <a href="https://opensource.org/licenses/MIT"></a> <a href="https://discord.gg/bloc"></a> <a href="https://github.com/felangel/bloc"></a> </p>

Overview

VSCode support for the Bloc Library and provides tools for effectively creating Blocs and Cubits for both Flutter and AngularDart apps.

Installation

Bloc can be installed from the VSCode Marketplace or by searching within VSCode.

Language Server

By default, the bloc language server started which enables custom bloc diagnotic reporting. See the official documentation for more information about configuring the linter and the various supported lint rules.

Commands

CommandDescription
Bloc: New BlocGenerate a new Bloc
Cubit: New CubitGenerate a new Cubit

You can activate the commands by launching the command palette (View -> Command Palette) and running entering the command name or you can right click on the directory in which you'd like to create the bloc/cubit and select the command from the context menu.

Code Actions

ActionDescription
Convert to MultiBlocListenerConverts current BlocListener into a MultiBlocListener
Convert to MultiBlocProviderConverts current BlocProvider into a MultiBlocProvider
Convert to MultiRepositoryProviderConverts current RepositoryProvider into a MultiRepositoryProvider
Wrap with BlocBuilderWraps current widget in a BlocBuilder
Wrap with BlocSelectorWraps current widget in a BlocSelector
Wrap with BlocListenerWraps current widget in a BlocListener
Wrap with BlocConsumerWraps current widget in a BlocConsumer
Wrap with BlocProviderWraps current widget in a BlocProvider
Wrap with RepositoryProviderWraps current widget in a RepositoryProvider

Snippets

Bloc

ShortcutDescription
importblocImports package:bloc
importflutterblocImports package:flutter_bloc
importbloctestImports package:bloc_test
blocCreates a bloc class
cubitCreates a cubit class
oneventRegister a new EventHandler
_oneventDefine a new EventHandler
blocobserverCreates a BlocObserver class
blocproviderCreates a BlocProvider widget
multiblocproviderCreates a MultiBlocProvider widget
repoproviderCreates a RepositoryProvider widget
multirepoproviderCreates a MultiRepositoryProvider widget
blocbuilderCreates a BlocBuilder widget
blocselectorCreates a BlocSelector widget
bloclistenerCreates a BlocListener widget
multibloclistenerCreates a MultiBlocListener widget
blocconsumerCreates a BlocConsumer widget
blocofShortcut for BlocProvider.of()
repoofShortcut for RepositoryProvider.of()
readShortcut for context.read()
watchShortcut for context.watch()
selectShortcut for context.select()
blocstateCreates a state class
bloceventCreates an event class
bloctestCreates a blocTest
mockblocCreates a class extending MockBloc
_mockblocCreates a private class extending MockBloc
mockcubitCreates a class extending MockCubit
_mockcubitCreates a private class extending MockCubit
fakeCreates a class extending Fake
_fakeCreates a private class extending Fake
mockCreates a class extending Mock
_mockCreates a private class extending Mock

Freezed Bloc

ShortcutDescription
fstateCreates a freezed state
feventCreates a freezed event