feat: update feature brick

This commit is contained in:
Hugo Pointcheval 2023-01-20 11:50:14 +01:00
parent 6286d348f8
commit d43ace5219
Signed by: hugo
GPG Key ID: 3AAC487E131E00BC
55 changed files with 288 additions and 500 deletions

View File

@ -1 +1 @@
include: package:wyatt_analysis/analysis_options.flutter.experimental.yaml
include: package:wyatt_analysis/analysis_options.flutter.yaml

View File

@ -1,13 +0,0 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks

View File

@ -1,71 +0,0 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.wyatt_feature_brick"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

View File

@ -1,8 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wyatt_feature_brick">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

View File

@ -1,34 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wyatt_feature_brick">
<application
android:label="wyatt_feature_brick"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

View File

@ -1,6 +0,0 @@
package com.example.wyatt_feature_brick
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@ -1,8 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wyatt_feature_brick">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

View File

@ -1,31 +0,0 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -1,3 +0,0 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true

View File

@ -1,6 +0,0 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

View File

@ -1,11 +0,0 @@
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

View File

@ -1,20 +1,13 @@
brick_name: wyatt_feature_brick
name: wyatt_feature_brick
description: New feature brick including state mananement
path_to_brickify: lib/feature_name
variables:
version: 0.1.1
vars:
feature_name:
variable_name: feature_name
type: string
syntax:
camel_case: featureName
constant_case: FEATURE_NAME
dot_case: feature.name
header_case: Feature-Name
lower_case: feature name
pascal_case: FeatureName
param_case: feature-name
sentence_case: Feature name
title_case: Feature Name
upper_case: FEATURE NAME
snake_case: feature_name
name: feature_name
description: Name of the feature
default: Dash
prompt: What is the name of your new feature

View File

@ -6,7 +6,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
part 'feature_name_event.dart';
part 'feature_name_state.dart';
/// {@template feature_name_bloc}
/// FeatureNameBloc description
/// {@endtemplate}
class FeatureNameBloc extends Bloc<FeatureNameEvent, FeatureNameState> {
/// {@macro feature_name_bloc}
FeatureNameBloc() : super(const FeatureNameInitial()) {
on<CustomFeatureNameEvent>(_onCustomFeatureNameEvent);
}
@ -14,7 +18,9 @@ class FeatureNameBloc extends Bloc<FeatureNameEvent, FeatureNameState> {
FutureOr<void> _onCustomFeatureNameEvent(
CustomFeatureNameEvent event,
Emitter<FeatureNameState> emit,
) {
// TODO(wyattstudio): Add Logic
) async {
// TODO(wyatt): Add custom UI logic
const _ = 1 + 1;
return;
}
}

View File

@ -1,6 +1,10 @@
part of 'feature_name_bloc.dart';
/// {@template feature_name_event}
/// FeatureNameEvent description
/// {@endtemplate}
abstract class FeatureNameEvent extends Equatable {
/// {@macro feature_name_event}
const FeatureNameEvent();
}

View File

@ -5,11 +5,17 @@ import 'package:flutter_bloc/flutter_bloc.dart';
part 'feature_name_state.dart';
/// {@template feature_name_cubit}
/// FeatureNameCubit description
/// {@endtemplate}
class FeatureNameCubit extends Cubit<FeatureNameState> {
/// {@macro feature_name_cubit}
FeatureNameCubit() : super(const FeatureNameInitial());
/// A description for yourCustomFunction
FutureOr<void> yourCustomFunction() {
// TODO(wyattstudio): Add Logic
FutureOr<void> yourCustomFunction() async {
// TODO(wyatt): Add custom UI logic
const _ = 1 + 1;
return;
}
}

View File

@ -1 +1,2 @@
export './state_management/feature_name_state_management.dart';
export 'screens/feature_name_provider.dart';
export 'screens/feature_name_screen.dart';

View File

@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
class FeatureNameParent extends StatelessWidget {
const FeatureNameParent({
required this.child,
super.key,
});
final Widget child;
@override
Widget build(BuildContext context) => Scaffold(
body: SafeArea(child: child),
);
}

View File

@ -0,0 +1,22 @@
// ignore_for_file: always_use_package_imports
import 'package:flutter/material.dart';
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
import '../blocs/feature_name_cubit/feature_name_cubit.dart';
import 'widgets/feature_name_consumer_widget.dart';
/// {@template feature_name_provider}
/// FeatureNameProvider provides bloc to his children.
/// {@endtemplate}
class FeatureNameProvider
extends CubitProviderScreen<FeatureNameCubit, FeatureNameState> {
/// {@macro feature_name_provider}
const FeatureNameProvider({super.key});
@override
FeatureNameCubit create(BuildContext context) => FeatureNameCubit();
@override
Widget builder(BuildContext context) => const FeatureNameConsumerWidget();
}

View File

@ -0,0 +1,33 @@
// ignore_for_file: always_use_package_imports
import 'package:flutter/material.dart';
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
import '../blocs/feature_name_cubit/feature_name_cubit.dart';
import '../stateless/feature_name_widget.dart';
import 'feature_name_parent.dart';
/// {@template feature_name_screen}
/// FeatureNameScreen is the merge of Provider and Consumer.
/// {@endtemplate}
class FeatureNameScreen
extends CubitScreen<FeatureNameCubit, FeatureNameState> {
/// {@macro feature_name_screen}
const FeatureNameScreen({super.key});
@override
FeatureNameCubit create(BuildContext context) => FeatureNameCubit();
@override
FeatureNameCubit init(BuildContext context, FeatureNameCubit bloc) =>
bloc..yourCustomFunction();
@override
Widget parent(BuildContext context, Widget child) =>
FeatureNameParent(child: child);
// Rebuild on every bloc changes
@override
Widget onBuild(BuildContext context, FeatureNameState state) =>
const FeatureNameWidget();
}

View File

@ -0,0 +1,18 @@
// ignore_for_file: always_use_package_imports
import 'package:flutter/material.dart';
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
import '../../blocs/feature_name_cubit/feature_name_cubit.dart';
/// {@template feature_name_consumer_widget}
/// FeatureNameConsumerWidget is a stateful widget. Aware of state changes.
/// {@endtemplate}
class FeatureNameConsumerWidget
extends CubitConsumerScreen<FeatureNameCubit, FeatureNameState> {
/// {@macro feature_name_sf_widget}
const FeatureNameConsumerWidget({super.key});
@override
Widget onBuild(BuildContext context, FeatureNameState state) => Container();
}

View File

@ -1,25 +0,0 @@
import 'package:flutter/material.dart';
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
// ignore: always_use_package_imports
import './feature_name_wrapper_widget.dart';
// ignore: always_use_package_imports
import './widgets/feature_name_widget.dart';
// ignore: always_use_package_imports
import '../cubit/feature_name_cubit.dart';
class FeatureNameCubitStateManagement
extends CubitScreen<FeatureNameCubit, FeatureNameState> {
const FeatureNameCubitStateManagement({super.key});
@override
FeatureNameCubit create(BuildContext context) => FeatureNameCubit();
@override
Widget onWrap(BuildContext context, Widget child) =>
FeatureNameWrapperWidget(child: child);
@override
Widget onBuild(BuildContext context, FeatureNameState state) =>
const FeatureNameWidget();
}

View File

@ -1,14 +0,0 @@
import 'package:flutter/material.dart';
class FeatureNameWrapperWidget extends StatelessWidget {
final Widget child;
const FeatureNameWrapperWidget({
required this.child,
super.key,
});
@override
Widget build(BuildContext context) => Container(
child: child,
);
}

View File

@ -1,8 +0,0 @@
import 'package:flutter/material.dart';
class FeatureNameWidget extends StatelessWidget {
const FeatureNameWidget({super.key});
@override
Widget build(BuildContext context) => const SizedBox();
}

View File

@ -0,0 +1,12 @@
import 'package:flutter/material.dart';
/// {@template feature_name_widget}
/// FeatureNameWidget is a stateless widget. (Not aware of cubit or bloc states)
/// {@endtemplate}
class FeatureNameWidget extends StatelessWidget {
/// {@macro feature_name_widget}
const FeatureNameWidget({super.key});
@override
Widget build(BuildContext context) => Container();
}

View File

@ -1,99 +1,33 @@
name: wyatt_feature_brick
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
publish_to: "none"
environment:
sdk: ">=2.17.6 <3.0.0"
sdk: ">=2.18.0 <3.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
flutter: { sdk: flutter }
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
flutter_bloc: ^8.0.1
equatable: ^2.0.3
wyatt_bloc_helper:
git:
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
ref: bloc/feature/fix_and_repo
path: packages/wyatt_bloc_helper
hosted:
url: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
name: wyatt_bloc_helper
version: 2.0.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_test: { sdk: flutter }
wyatt_analysis:
git:
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
ref: wyatt_analysis-v2.1.0
path: packages/wyatt_analysis
hosted:
url: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
name: wyatt_analysis
version: 2.3.0
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

View File

@ -1,30 +0,0 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:wyatt_feature_brick/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}

View File

@ -1,3 +0,0 @@
# 0.1.0+1
- TODO: Describe initial release.

View File

@ -1 +0,0 @@
TODO: Add your license here.

View File

@ -2,15 +2,12 @@
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason)
A brick to create a feature using best practices and your state management of choice! Supports Bloc & Cubit.
## How to use 🚀
```
mason make feature_brick --feature_name audit --state_management cubit --use_equatable true
mason make feature_brick --feature_name audit
```
## Variables ✨
@ -22,25 +19,34 @@ mason make feature_brick --feature_name audit --state_management cubit --use_equ
## Outputs 📦
### Using Bloc
```shell
--feature_name login --state_management bloc
--feature_name feature
```
```
├── feature
│ ├── blocs
| | └── feature_bloc
│ │ ├── feature_bloc.dart
│ │ ├── feature_event.dart
│ │ ├── feature_bloc
│ │ │ ├── feature_bloc.dart
│ │ │ ├── feature_event.dart
│ │ │ └── feature_state.dart
│ │ └── feature_cubit
│ │ ├── feature_cubit.dart
│ │ └── feature_state.dart
│ ├── state_management
| | └── ...
│ ├── screens
│ │ ├── widgets
│ │ │ └── feature_consumer_widget.dart
│ │ ├── feature_parent.dart
│ │ ├── feature_provider.dart
│ │ └── feature_screen.dart
│ ├── stateless
│ │ └── feature_widget.dart
│ └── feature.dart
└── ...
```
## Using BLoC
- {{featureName}}_bloc.dart
```dart

View File

@ -6,7 +6,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
part '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_event.dart';
part '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_state.dart';
/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_bloc}
/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Bloc description
/// {@endtemplate}
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Bloc extends Bloc<{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State> {
/// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_bloc}
{{#pascalCase}}{{feature_name}}{{/pascalCase}}Bloc() : super(const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Initial()) {
on<Custom{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event>(_onCustom{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event);
}
@ -14,7 +18,9 @@ class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Bloc extends Bloc<{{#pascalC
FutureOr<void> _onCustom{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event(
Custom{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event event,
Emitter<{{#pascalCase}}{{feature_name}}{{/pascalCase}}State> emit,
) {
// TODO(wyattstudio): Add Logic
) async {
// TODO(wyatt): Add custom UI logic
const _ = 1 + 1;
return;
}
}

View File

@ -1,6 +1,10 @@
part of '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_bloc.dart';
/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_event}
/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Event description
/// {@endtemplate}
abstract class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Event extends Equatable {
/// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_event}
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Event();
}

View File

@ -5,11 +5,17 @@ import 'package:flutter_bloc/flutter_bloc.dart';
part '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_state.dart';
/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit}
/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit description
/// {@endtemplate}
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit extends Cubit<{{#pascalCase}}{{feature_name}}{{/pascalCase}}State> {
/// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit}
{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit() : super(const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Initial());
/// A description for yourCustomFunction
FutureOr<void> yourCustomFunction() {
// TODO(wyattstudio): Add Logic
FutureOr<void> yourCustomFunction() async {
// TODO(wyatt): Add custom UI logic
const _ = 1 + 1;
return;
}
}

View File

@ -0,0 +1,18 @@
// ignore_for_file: always_use_package_imports
import 'package:flutter/material.dart';
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
import '../../blocs/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit.dart';
/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_consumer_widget}
/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}ConsumerWidget is a stateful widget. Aware of state changes.
/// {@endtemplate}
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}ConsumerWidget
extends CubitConsumerScreen<{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State> {
/// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_sf_widget}
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}ConsumerWidget({super.key});
@override
Widget onBuild(BuildContext context, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State state) => Container();
}

View File

@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Parent extends StatelessWidget {
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Parent({
required this.child,
super.key,
});
final Widget child;
@override
Widget build(BuildContext context) => Scaffold(
body: SafeArea(child: child),
);
}

View File

@ -0,0 +1,22 @@
// ignore_for_file: always_use_package_imports
import 'package:flutter/material.dart';
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
import '../blocs/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit.dart';
import 'widgets/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_consumer_widget.dart';
/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_provider}
/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Provider provides bloc to his children.
/// {@endtemplate}
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Provider
extends CubitProviderScreen<{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State> {
/// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_provider}
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Provider({super.key});
@override
{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit create(BuildContext context) => {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit();
@override
Widget builder(BuildContext context) => const {{#pascalCase}}{{feature_name}}{{/pascalCase}}ConsumerWidget();
}

View File

@ -0,0 +1,33 @@
// ignore_for_file: always_use_package_imports
import 'package:flutter/material.dart';
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
import '../blocs/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit.dart';
import '../stateless/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_widget.dart';
import '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_parent.dart';
/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_screen}
/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Screen is the merge of Provider and Consumer.
/// {@endtemplate}
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Screen
extends CubitScreen<{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State> {
/// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_screen}
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Screen({super.key});
@override
{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit create(BuildContext context) => {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit();
@override
{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit init(BuildContext context, {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit bloc) =>
bloc..yourCustomFunction();
@override
Widget parent(BuildContext context, Widget child) =>
{{#pascalCase}}{{feature_name}}{{/pascalCase}}Parent(child: child);
// Rebuild on every bloc changes
@override
Widget onBuild(BuildContext context, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State state) =>
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget();
}

View File

@ -1,8 +0,0 @@
import 'package:flutter/material.dart';
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget extends StatelessWidget {
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget({super.key});
@override
Widget build(BuildContext context) => const SizedBox();
}

View File

@ -1,25 +0,0 @@
import 'package:flutter/material.dart';
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
// ignore: always_use_package_imports
import './{{#snakeCase}}{{feature_name}}{{/snakeCase}}_wrapper_widget.dart';
// ignore: always_use_package_imports
import './widgets/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_widget.dart';
// ignore: always_use_package_imports
import '../cubit/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit.dart';
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}CubitStateManagement
extends CubitScreen<{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State> {
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}CubitStateManagement({super.key});
@override
{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit create(BuildContext context) => {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit();
@override
Widget onWrap(BuildContext context, Widget child) =>
{{#pascalCase}}{{feature_name}}{{/pascalCase}}WrapperWidget(child: child);
@override
Widget onBuild(BuildContext context, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State state) =>
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget();
}

View File

@ -1,14 +0,0 @@
import 'package:flutter/material.dart';
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}WrapperWidget extends StatelessWidget {
final Widget child;
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}WrapperWidget({
required this.child,
super.key,
});
@override
Widget build(BuildContext context) => Container(
child: child,
);
}

View File

@ -0,0 +1,12 @@
import 'package:flutter/material.dart';
/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_widget}
/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget is a stateless widget. (Not aware of cubit or bloc states)
/// {@endtemplate}
class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget extends StatelessWidget {
/// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_widget}
const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget({super.key});
@override
Widget build(BuildContext context) => Container();
}

View File

@ -1 +1,2 @@
export './state_management/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_state_management.dart';
export 'screens/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_provider.dart';
export 'screens/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_screen.dart';

View File

@ -1,5 +1,5 @@
name: wyatt_feature_brick
description: new feature brick including state mananement
description: New feature brick including state mananement
version: 0.1.0+1