Skip to content

Commit fda18f9

Browse files
committed
Added more help classes, moved files to public
1 parent e34ecaa commit fda18f9

26 files changed

+833
-6
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.0.1+2
2+
3+
* Added a lot more help classes
4+
15
## 0.0.1+1
26

37
* Exposed Help classes

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Flutter dev utils to make your life easier
99
* CallerLogger
1010
* Built off logger package with functionality to print caller, ignore certain callers, and filter printed logs by caller type
1111
* Help
12-
* HelpFoo classes which can be used for inline code help.
12+
* Stop clicking those purple stackoverflow links! HelpFoo classes can be used for inline code help.
1313

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

lib/flutter_dev_utils.dart

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
library flutter_dev_utils;
22

3-
export 'package:flutter_dev_utils/src/inline_help/help_error.dart';
4-
export 'package:flutter_dev_utils/src/inline_help/help_singleton.dart';
5-
63
export 'package:flutter_dev_utils/src/try_handler/sync_try_handler.dart';
74
export 'package:flutter_dev_utils/src/try_handler/async_try_handler.dart';
85
export 'package:flutter_dev_utils/src/caller_logger/caller_logger.dart';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/// TODO
2+
/// # Help with Abstract classes
3+
///
4+
/// * Abstract classes cannot be instantiated.
5+
///
6+
/// ## Use cases
7+
///
8+
/// ### Extending an abstract class to override its function
9+
/// ```
10+
/// abstract class AbstractClass {
11+
/// void function();
12+
/// }
13+
///
14+
/// class Example extends AbstractClass {
15+
/// @override
16+
/// void function() => print('hi');
17+
/// }
18+
/// ```
19+
///
20+
/// ### Extending an abstract class to inherit its instance variable
21+
///
22+
/// * Instance variable has to be declared on instantiation of subclass.
23+
///
24+
/// ```
25+
/// abstract class AbstractClass {
26+
/// final String instanceVar;
27+
/// AbstractClass(this.instanceVar);
28+
/// }
29+
///
30+
/// class Example extends AbstractClass {
31+
/// Example(super.instanceVar);
32+
/// }
33+
/// ```
34+
///
35+
/// ### Implementing an abstract class to override its instance variable
36+
/// ```
37+
/// abstract class AbstractClass {
38+
/// final String instanceVar;
39+
/// AbstractClass(this.instanceVar);
40+
/// }
41+
///
42+
/// class Example implements AbstractClass {
43+
/// @override
44+
/// final String instanceVar = 'const';
45+
/// Example();
46+
/// }
47+
/// ```
48+
/// ### Mixing in an abstract class to inherit its instance variable
49+
///
50+
/// * Declaration of instance variable not necessary on instantiation of subclass
51+
///
52+
/// ```
53+
/// abstract class AbstractClass {
54+
/// String? instanceVar;
55+
/// }
56+
///
57+
/// class Example with AbstractClass {
58+
/// Example();
59+
/// }
60+
/// ```
61+
///
62+
/// ### Implementing an abstract class to inherit its members (interface)
63+
///
64+
/// * An interface is a superclass that acts as a blueprint for a subclass
65+
/// * Implementing an abstract class forces the subclass to override all members of the super
66+
/// * See HelpInterface for more details on `implements`
67+
///
68+
/// ```
69+
/// abstract class AbstractClass {
70+
/// String? instanceVariable;
71+
///
72+
/// void _function();
73+
/// }
74+
///
75+
/// class Example implements AbstractClass {
76+
/// @override
77+
/// void _function() => null;
78+
///
79+
/// @override
80+
/// String? instanceVariable = '';
81+
/// }
82+
/// ```
83+
84+
abstract class HelpAbstractClass {}

lib/inline_help/classes/help_annotations.dart

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// TODO
2+
abstract class HelpInterface {}

lib/inline_help/dart/help_dart.dart

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// Help with important concepts in Dart
2+
///
3+
///
4+
5+
class HelpDart {}
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/// # Help with Dart syntax
2+
///
3+
/// ## Multiple if
4+
/// ```
5+
/// (() {
6+
/// /// your code here
7+
/// }())
8+
/// ```
9+
///
10+
/// ## Spread Operator
11+
/// - Can be used to return multiple widgets
12+
/// ```
13+
/// if (Responsive.isDesktop()) ...[
14+
/// Text('Desktop')
15+
/// Text('Mode')
16+
/// ]
17+
/// ```
18+
///
19+
/// ## Cascade Notation
20+
///
21+
/// Prevents repeating target for several call methods on same object.
22+
///
23+
/// ```
24+
/// List list = [];
25+
/// list.add(color1);
26+
/// list.add(color2);
27+
///
28+
/// list
29+
/// ..add(color1)
30+
/// ..add(color2);
31+
/// ```
32+
///
33+
/// ## Arrow
34+
/// ```
35+
/// => expression,
36+
/// /// is equivalent to
37+
/// {return expression;},
38+
/// ```
39+
///
40+
/// ## Closure/Inline Functions
41+
/// ```
42+
/// () => expression
43+
///
44+
/// /// is equivalent to
45+
/// function () {
46+
/// return expression
47+
/// }
48+
/// ```
49+
///
50+
/// ## Anonymous Multiline Function
51+
/// ```
52+
/// () {expression}
53+
/// /// is equivalent to
54+
/// function () {
55+
/// return expression
56+
/// }
57+
/// ```
58+
class HelpDartSyntax {}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// # Inheritance
2+
///
3+
/// ## extends
4+
///
5+
/// - making all properties, variables, functions of superclass available to subclass
6+
///
7+
/// ## implements
8+
///
9+
/// - making type of superclass available to subclass
10+
/// - all functions must be implemented/overridden
11+
///
12+
/// ## with (mixin)
13+
///
14+
/// - making properties, variables, functions of a different class available to a subclass
15+
class HelpInheritance {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// # Initialiser List (:)
2+
///
3+
/// Used to:
4+
/// - Initialise list of expressions that can:
5+
/// - access constructor parameters
6+
/// - assign to instance fields (even final instance fields!)
7+
/// - Call other constructors
8+
/// - e.g., superclass
9+
/// - Assert constructor parameters
10+
///
11+
/// NOTE:
12+
/// - Initialiser list is executed before constructor body
13+
/// - Use `this.instanceVariable` when there is a name conflict, else omit
14+
class HelpInitialiserList {}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// # Modifiers
2+
///
3+
/// ## static
4+
///
5+
/// - modifies members of a class (variables, functions)
6+
/// - only affects the class, not on instances of the class
7+
///
8+
/// ## final
9+
///
10+
/// - modifies variables (`var, int, double`)
11+
/// - must be assigned on init
12+
/// - shallow immutability: e.g., final collection members can be mutable, collection itself is immutable
13+
///
14+
/// ## const
15+
///
16+
/// - modifies values and objects (`[1,2,3], Point(2,3)`)
17+
/// - 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)
18+
/// - deep (transitive) immutability: e.g., const collection members are immutable, recursively
19+
/// - canonicalised values and objects: all assignments of the const value/object will refer to the same instance
20+
class HelpModifiers {}

lib/inline_help/dart/help_sizing.dart

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/// # Sizing
2+
/// ## Sizes, Constraints and Positions
3+
/// ### Rules
4+
/// - Constraints go down
5+
/// - Sizes go up
6+
/// - Parent sets position
7+
/// ### Process
8+
/// For an arbitrary widget X, its parent Y, and its children Z
9+
/// 1. Y passes its constraints down to X
10+
/// - min/max height/width
11+
/// 2. X passes its constraints down to Z
12+
/// 3. X asks Z what size they are
13+
/// - width/height
14+
/// 4. X sets positions of Z
15+
/// 5. X tells Y its final size
16+
///
17+
/// ### Limitations
18+
/// - Size defined in widget only within constraints of parent
19+
/// - Widget does not know/decide its position
20+
/// - Defining alignment must be specific or child size may be ignored
21+
///
22+
/// ### Mechanisms
23+
/// - RenderBox
24+
/// - Underlying object used to render widgets
25+
///
26+
/// ### Types of Constraints
27+
/// #### As Big As Possible
28+
/// - e.g.,
29+
/// - Center
30+
/// - ListView
31+
/// - Container (null width and height)
32+
/// #### Same Size if Possible
33+
/// - e.g.,
34+
/// - Transform
35+
/// - Opacity
36+
/// - Container (non null width or height)
37+
/// #### Fixed Size if Possible
38+
/// - e.g.,
39+
/// - Image
40+
/// - Text
41+
/// ## BoxConstraints
42+
/// - Passed to Container.constraints
43+
/// - Can specify max/min width/height
44+
///
45+
/// ## LayoutBuilder
46+
/// - Provides parent constraints to child
47+
/// - Builds at layout time
48+
///
49+
/// ## FractionallySizedBox
50+
/// - Provides percentage of parent size to child
51+
/// ```
52+
/// ParentWidget(
53+
/// child: FractionallySizedBox(
54+
/// widthFactor: 0.5,
55+
/// heightFactor: 0.5,
56+
/// child: Container(
57+
/// /// this container won't be larger than
58+
/// /// half of its parent size
59+
/// ),
60+
/// )
61+
/// )
62+
/// ```
63+
class HelpSizing {}

lib/src/inline_help/help_error.dart renamed to lib/inline_help/debugging/help_error.dart

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/// # Errors
2+
/// An Error in Dart should be thrown for unexpected program flow and should not be caught but addressed by the programmer:
3+
/// Error and its subclasses are for programmatic errors. If one of those occurs, your code is bad and you should fix your code.
4+
/// 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.
5+
///
16
/// Flutter Error Types:
27
///
38
/// * ArgumentError
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// # Exceptions
2+
///
3+
/// An Exception in Dart should be thrown for regular, expected program flow and is intended to be caught:
4+
/// 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.
5+
class HelpExceptions {}

0 commit comments

Comments
 (0)