flutter_simple_template_bloc

Last updated:

0 purchases

flutter_simple_template_bloc Image
flutter_simple_template_bloc Images
Add to Cart

Description:

flutter simple template bloc

flutter_simple_template_bloc #
A package to make app easy. Using BLoC
Features #

Base bloc
Tool : Debouncer, Extensions, Http certificate, Page route transition, service control center (navigation, dialog, camera, snack bar), shimmer,

Supported platforms #

Android
IOS
Web

Note #
1. Edit permision with your app on Podfile ( remove comment when you using)
<--
post_install do |installer|
installer.pods_project.targets.each do |target|
... # Here are some configurations automatically generated by flutter

# Start of the permission_handler configuration
target.build_configurations.each do |config|

# You can enable the permissions needed here. For example to enable camera
# permission, just remove the `#` character in front so it looks like this:
#
# ## dart: PermissionGroup.camera
# 'PERMISSION_CAMERA=1'
#
# Preprocessor definitions can be found in: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',

## dart: PermissionGroup.calendar
# 'PERMISSION_EVENTS=1',

## dart: PermissionGroup.reminders
# 'PERMISSION_REMINDERS=1',

## dart: PermissionGroup.contacts
# 'PERMISSION_CONTACTS=1',

## dart: PermissionGroup.camera
# 'PERMISSION_CAMERA=1',

## dart: PermissionGroup.microphone
# 'PERMISSION_MICROPHONE=1',

## dart: PermissionGroup.speech
# 'PERMISSION_SPEECH_RECOGNIZER=1',

## dart: PermissionGroup.photos
# 'PERMISSION_PHOTOS=1',

## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
# 'PERMISSION_LOCATION=1',

## dart: PermissionGroup.notification
# 'PERMISSION_NOTIFICATIONS=1',

## dart: PermissionGroup.mediaLibrary
# 'PERMISSION_MEDIA_LIBRARY=1',

## dart: PermissionGroup.sensors
# 'PERMISSION_SENSORS=1',

## dart: PermissionGroup.bluetooth
# 'PERMISSION_BLUETOOTH=1',

## dart: PermissionGroup.appTrackingTransparency
# 'PERMISSION_APP_TRACKING_TRANSPARENCY=1',

## dart: PermissionGroup.criticalAlerts
# 'PERMISSION_CRITICAL_ALERTS=1'
]
end
# End of the permission_handler configuration
end
end
-->
2. Open file ./setup.sh and run command No.4 to clean cache and generate file.g.dart
copied to clipboard
How to use #
0. create structure follow example

1. create file locator.dart , set file into it then run build_runner

final GetIt locator = GetIt.instance;
void setup() {
// DataRepository to restful API
locator.registerLazySingleton<DataRepository>(() => DataRepository());
// Storage data local
locator.registerLazySingleton<AppPrefs>(() => AppPrefs.instance());
// Service other below here...
}

2. In main.dart

import 'package:your_package/locator.dart' as locator;
void main() async {
...
locator.setup();
}

2. create base_bloc.dart extends generic_base_bloc.dart and handle follow thread app

class BaseBloc<Event, State> extends GenericBaseBloc<Event, State> {
BaseBloc(State state) : super(state);

DataRepository get dataRepository => locator<DataRepository>();
AppPrefs get appPrefs => locator<AppPrefs>();

... call function avalable that your project need . Ex: showLoading(), dismissLoading()

@override
void hideLoading() {
navigatorKey.currentState?.pop();
super.hideLoading();
}

@override
void showLoading() {
showDialog(
barrierDismissible: false,
context: navigatorKey.currentContext!,
builder: (BuildContext context) => WillPopScope(
onWillPop: () async => false,
child: const AlertDialog(
backgroundColor: Colors.transparent,
elevation: 0,
content: SpinKitFadingCircle(
color: Colors.white,
),
),
),
);
super.showLoading();
}
}

4. using base_bloc.dart to create bloc for your screen

class DemoBloc extends BaseBloc<DemoEvent, DemoState> {
DemoBloc() : super(const DemoState()) {
on<DemoInit>((event, emit) async {
// write your logic
});
}
}

3. create page extends base_stateless_widget.dart

class DemoScreen extends BaseStatelessWidget<DemoBloc, DemoState> {
final YourParams yourParams;

const DemoScreen({super.key,required this.yourParams});

static BlocProvider<DemoBloc> provider({
required YourParams yourParams, // if any
}) =>
BlocProvider(
create: (_) => DemoBloc(),
child: DemoScreen(
yourParams: yourParams,
),
);

@override
Widget builder(BuildContext context, DemoState state) {}

... call other method if this page need
}
copied to clipboard
Info me #
if i have mistake please send me message , very happy if you do that ❤️ ❤️
[email protected]

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.