For Android Studio user, it would be fine to have template for bloc generation.
Is it in your plans ?
@fvisticot There is currently support for VSCode and I am planning on extending the extension to create the bloc as well as the states and events.
Not sure when I'll get to Android Studio but you're more than welcome to contribute 馃槃
Ideally, the Android Studio Plugin functionality should align with the VSCode extension (#118).
Use Uber's RIBs Plugin for reference.
I have some experience with code templates in IntelliJ... I can work on it ;)
@felangel we should agree on some conventions first before we do any coding, so we keep the IntelliJ plugin and VS Code in sync. What about?
XXX_bloc.dart
XXX_event.dart
XXX_state.dart
bloc.dart
and contents:
export 'XXX_bloc.dart';
export 'XXX_event.dart';
export 'XXX_state.dart';
import 'package:equatable/equatable.dart';
abstract class XXXEvent extends Equatable {
XXXEvent([List props = const []]) : super(props);
}
import 'package:equatable/equatable.dart';
abstract class XXXState extends Equatable {
XXXState([List props = const []]) : super(props);
}
import 'dart:async';
import 'package:bloc/bloc.dart';
class XXXBloc
extends Bloc<XXXEvent, XXXState> {
@override
ResetPasswordUiState get initialState => throw Exception('Complete your initialState');
@override
Stream<XXXState> mapEventToState(
XXXState state, XXXEvent event) async* {
throw Exception('Complete your mapEventToState');
}
}
I think that might be all we need, right?
@jorgecoca that looks good to me 馃憤
I鈥檒l let you know if I run into anything we haven鈥檛 considered as I make progress on the VSCode extension.
Hello everyone,
While there is no plugin for android studio you can simply do following:
Add bloc template in settings:
Add Template text:
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'dart:async';
class $NAME$Bloc extends Bloc<$NAME$Event, $NAME$State> {
@override
$NAME$State get initialState => null;// TODO: initial state
@override
Stream<$NAME$State> mapEventToState($NAME$State currentState, $NAME$Event event) async* {
// TODO: implement mapEventToState
}
}
abstract class $NAME$State extends Equatable {
$NAME$State([List props = const []]) : super(props);
}
abstract class $NAME$Event extends Equatable {
$NAME$Event([List props = const []]) : super(props);
}
Go back to editor and start typing blo
:
Hit enter, give NAME for your bloc and you'll have following:
Have a nice day!
Good job,
The solution is working but I think original proposal allowing to generate multiple files with proposed convention will result in better code organisation / evolution
Good job,
The solution is working but I think original proposal allowing to generate multiple files with proposed convention will result in better code organisation / evolution
Totally agree.
I've posted temporary solution.
But you know how it is... permanent temporary solution :laughing:
@jorgecoca will most likely have the permanent solution done relatively quickly 馃帀馃挴
By the end of this I hope to have something up and running ;)
You guys are awesome!
@jorgecoca is awesome 馃
I opened #148 ;)
merged in #148
Most helpful comment
I have some experience with code templates in IntelliJ... I can work on it ;)