Skip to content

Commit

Permalink
Added more help classes, moved files to public
Browse files Browse the repository at this point in the history
  • Loading branch information
juskek committed Oct 3, 2022
1 parent e34ecaa commit fda18f9
Show file tree
Hide file tree
Showing 26 changed files with 833 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.1+2

* Added a lot more help classes

## 0.0.1+1

* Exposed Help classes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Flutter dev utils to make your life easier
* CallerLogger
* Built off logger package with functionality to print caller, ignore certain callers, and filter printed logs by caller type
* Help
* HelpFoo classes which can be used for inline code help.
* Stop clicking those purple stackoverflow links! HelpFoo classes can be used for inline code help.

![Alt Text](https://github.com/Kek-Tech/flutter_dev_utils/blob/main/assets/HelpClass.gif)

Expand Down
3 changes: 0 additions & 3 deletions lib/flutter_dev_utils.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
library flutter_dev_utils;

export 'package:flutter_dev_utils/src/inline_help/help_error.dart';
export 'package:flutter_dev_utils/src/inline_help/help_singleton.dart';

export 'package:flutter_dev_utils/src/try_handler/sync_try_handler.dart';
export 'package:flutter_dev_utils/src/try_handler/async_try_handler.dart';
export 'package:flutter_dev_utils/src/caller_logger/caller_logger.dart';
Expand Down
84 changes: 84 additions & 0 deletions lib/inline_help/classes/help_abstract_class.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/// TODO
/// # Help with Abstract classes
///
/// * Abstract classes cannot be instantiated.
///
/// ## Use cases
///
/// ### Extending an abstract class to override its function
/// ```
/// abstract class AbstractClass {
/// void function();
/// }
///
/// class Example extends AbstractClass {
/// @override
/// void function() => print('hi');
/// }
/// ```
///
/// ### Extending an abstract class to inherit its instance variable
///
/// * Instance variable has to be declared on instantiation of subclass.
///
/// ```
/// abstract class AbstractClass {
/// final String instanceVar;
/// AbstractClass(this.instanceVar);
/// }
///
/// class Example extends AbstractClass {
/// Example(super.instanceVar);
/// }
/// ```
///
/// ### Implementing an abstract class to override its instance variable
/// ```
/// abstract class AbstractClass {
/// final String instanceVar;
/// AbstractClass(this.instanceVar);
/// }
///
/// class Example implements AbstractClass {
/// @override
/// final String instanceVar = 'const';
/// Example();
/// }
/// ```
/// ### Mixing in an abstract class to inherit its instance variable
///
/// * Declaration of instance variable not necessary on instantiation of subclass
///
/// ```
/// abstract class AbstractClass {
/// String? instanceVar;
/// }
///
/// class Example with AbstractClass {
/// Example();
/// }
/// ```
///
/// ### Implementing an abstract class to inherit its members (interface)
///
/// * An interface is a superclass that acts as a blueprint for a subclass
/// * Implementing an abstract class forces the subclass to override all members of the super
/// * See HelpInterface for more details on `implements`
///
/// ```
/// abstract class AbstractClass {
/// String? instanceVariable;
///
/// void _function();
/// }
///
/// class Example implements AbstractClass {
/// @override
/// void _function() => null;
///
/// @override
/// String? instanceVariable = '';
/// }
/// ```
abstract class HelpAbstractClass {}
Empty file.
2 changes: 2 additions & 0 deletions lib/inline_help/classes/help_interface.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// TODO
abstract class HelpInterface {}
File renamed without changes.
5 changes: 5 additions & 0 deletions lib/inline_help/dart/help_dart.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// Help with important concepts in Dart
///
///
class HelpDart {}
58 changes: 58 additions & 0 deletions lib/inline_help/dart/help_dart_syntax.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/// # Help with Dart syntax
///
/// ## Multiple if
/// ```
/// (() {
/// /// your code here
/// }())
/// ```
///
/// ## Spread Operator
/// - Can be used to return multiple widgets
/// ```
/// if (Responsive.isDesktop()) ...[
/// Text('Desktop')
/// Text('Mode')
/// ]
/// ```
///
/// ## Cascade Notation
///
/// Prevents repeating target for several call methods on same object.
///
/// ```
/// List list = [];
/// list.add(color1);
/// list.add(color2);
///
/// list
/// ..add(color1)
/// ..add(color2);
/// ```
///
/// ## Arrow
/// ```
/// => expression,
/// /// is equivalent to
/// {return expression;},
/// ```
///
/// ## Closure/Inline Functions
/// ```
/// () => expression
///
/// /// is equivalent to
/// function () {
/// return expression
/// }
/// ```
///
/// ## Anonymous Multiline Function
/// ```
/// () {expression}
/// /// is equivalent to
/// function () {
/// return expression
/// }
/// ```
class HelpDartSyntax {}
15 changes: 15 additions & 0 deletions lib/inline_help/dart/help_inheritance.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// # Inheritance
///
/// ## extends
///
/// - making all properties, variables, functions of superclass available to subclass
///
/// ## implements
///
/// - making type of superclass available to subclass
/// - all functions must be implemented/overridden
///
/// ## with (mixin)
///
/// - making properties, variables, functions of a different class available to a subclass
class HelpInheritance {}
14 changes: 14 additions & 0 deletions lib/inline_help/dart/help_initialiser_list.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// # Initialiser List (:)
///
/// Used to:
/// - Initialise list of expressions that can:
/// - access constructor parameters
/// - assign to instance fields (even final instance fields!)
/// - Call other constructors
/// - e.g., superclass
/// - Assert constructor parameters
///
/// NOTE:
/// - Initialiser list is executed before constructor body
/// - Use `this.instanceVariable` when there is a name conflict, else omit
class HelpInitialiserList {}
20 changes: 20 additions & 0 deletions lib/inline_help/dart/help_modifiers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// # Modifiers
///
/// ## static
///
/// - modifies members of a class (variables, functions)
/// - only affects the class, not on instances of the class
///
/// ## final
///
/// - modifies variables (`var, int, double`)
/// - must be assigned on init
/// - shallow immutability: e.g., final collection members can be mutable, collection itself is immutable
///
/// ## const
///
/// - modifies values and objects (`[1,2,3], Point(2,3)`)
/// - compile time constant: state can be determined at compile time and is then frozen (e.g., `1+2` is compile time const, `DateTime.now()` is not)
/// - deep (transitive) immutability: e.g., const collection members are immutable, recursively
/// - canonicalised values and objects: all assignments of the const value/object will refer to the same instance
class HelpModifiers {}
63 changes: 63 additions & 0 deletions lib/inline_help/dart/help_sizing.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/// # Sizing
/// ## Sizes, Constraints and Positions
/// ### Rules
/// - Constraints go down
/// - Sizes go up
/// - Parent sets position
/// ### Process
/// For an arbitrary widget X, its parent Y, and its children Z
/// 1. Y passes its constraints down to X
/// - min/max height/width
/// 2. X passes its constraints down to Z
/// 3. X asks Z what size they are
/// - width/height
/// 4. X sets positions of Z
/// 5. X tells Y its final size
///
/// ### Limitations
/// - Size defined in widget only within constraints of parent
/// - Widget does not know/decide its position
/// - Defining alignment must be specific or child size may be ignored
///
/// ### Mechanisms
/// - RenderBox
/// - Underlying object used to render widgets
///
/// ### Types of Constraints
/// #### As Big As Possible
/// - e.g.,
/// - Center
/// - ListView
/// - Container (null width and height)
/// #### Same Size if Possible
/// - e.g.,
/// - Transform
/// - Opacity
/// - Container (non null width or height)
/// #### Fixed Size if Possible
/// - e.g.,
/// - Image
/// - Text
/// ## BoxConstraints
/// - Passed to Container.constraints
/// - Can specify max/min width/height
///
/// ## LayoutBuilder
/// - Provides parent constraints to child
/// - Builds at layout time
///
/// ## FractionallySizedBox
/// - Provides percentage of parent size to child
/// ```
/// ParentWidget(
/// child: FractionallySizedBox(
/// widthFactor: 0.5,
/// heightFactor: 0.5,
/// child: Container(
/// /// this container won't be larger than
/// /// half of its parent size
/// ),
/// )
/// )
/// ```
class HelpSizing {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/// # Errors
/// An Error in Dart should be thrown for unexpected program flow and should not be caught but addressed by the programmer:
/// Error and its subclasses are for programmatic errors. If one of those occurs, your code is bad and you should fix your code.
/// Except in a few special circumstances, idiomatic Dart should throw Errors, but never catch them. They exists specifically to not be caught so that they take down the app and alert the programmer to the location of the bug.
///
/// Flutter Error Types:
///
/// * ArgumentError
Expand Down
5 changes: 5 additions & 0 deletions lib/inline_help/debugging/help_exceptions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// # Exceptions
///
/// An Exception in Dart should be thrown for regular, expected program flow and is intended to be caught:
/// An Exception is intended to convey information to the user about a failure, so that the error can be addressed programmatically. It is intended to be caught, and it should contain useful data fields.
class HelpExceptions {}
Loading

0 comments on commit fda18f9

Please sign in to comment.