Skip to content

A Neovim plugin for generating Bloc and Cubit boilerplate code.

License

Notifications You must be signed in to change notification settings

wa11breaker/flutter-bloc.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flutter-bloc.nvim

A Neovim plugin for generating bloc and cubit boilerplate code with support for code actions.

Screen.Recording.2024-03-03.at.8.36.46.PM.mov

Features

  • Generate bloc boiler plate code
  • Generate cubit boiler plate code
  • Code actions

Installation

{
  'wa11breaker/flutter-bloc.nvim',
  dependencies = {
      "nvimtools/none-ls.nvim", -- Required for code actions
  },
  opts = {
    bloc_type = 'default', -- Choose from: 'default', 'equatable', 'freezed'
    use_sealed_classes = false,
    enable_code_actions = true,
  }
}
use {
  'wa11breaker/flutter-bloc.nvim',
  requires = {
    'nvimtools/none-ls.nvim',
  },
  config = function()
    require('flutter-bloc').setup({
      bloc_type = 'default', -- Choose from: 'default', 'equatable', 'freezed'
      use_sealed_classes = false,
      enable_code_actions = true,
    })
  end
}

Configuration Options

Note

Currently doesn't support plugin invocation from tree explorer to generate bloc inside a folder. You will get 'attempt to concatenate local 'buf_directory' (a nil value)' as the buf_direcotry will be nil.

  • bloc_type: Specifies the type of BLoC generation

    • 'default': Standard BLoC generation
    • 'equatable': Uses Equatable for equality comparisons
    • 'freezed': Generates code with Freezed immutable classes
  • use_sealed_classes: Enables or disables sealed classes generation

Usage

Built-in Commands

Commands

  • :FlutterCreateBloc - Create a new Bloc
  • :FlutterCreateCubit - Create a new Cubit

Code Actions

  • Wrap with BlocBuilder
  • Wrap with BlocSelector
  • Wrap with BlocListener
  • Wrap with BlocConsumer
  • Wrap with BlocProvider
  • Wrap with RepositoryProvider

Custom Key Mappings

You can add custom key mappings to streamline your workflow:

-- Create BLoC quickly
vim.keymap.set("n", "<Leader>cfb", "<cmd>lua require('flutter-bloc').create_bloc()<cr>", {
  desc = '[C]reate [F]lutter [B]loc'
})

-- Create Cubit quickly
vim.keymap.set("n", "<Leader>cfc", "<cmd>lua require('flutter-bloc').create_cubit()<cr>", {
  desc = '[C]reate [F]lutter [C]ubit'
})

Documentation

For detailed documentation and advanced usage, refer to the help file:

  • :help flutter-bloc.nvim

About

A Neovim plugin for generating Bloc and Cubit boilerplate code.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages