Nipodemos

first steps in documenting code

1 import 'package:flutter/widgets.dart'; 1 import 'package:flutter/widgets.dart';
2 2
3 extension MDQ on BuildContext { 3 extension MDQ on BuildContext {
  4 + /// The same of [MediaQuery.of(context).size]
4 Size get mediaQuerySize => MediaQuery.of(this).size; 5 Size get mediaQuerySize => MediaQuery.of(this).size;
5 6
  7 + /// The same of [MediaQuery.of(context).size.height]
  8 + /// Note: updates when you rezise your screen (like on a browser or desktop window)
6 double get height => mediaQuerySize.height; 9 double get height => mediaQuerySize.height;
7 10
  11 + /// The same of [MediaQuery.of(context).size.width]
  12 + /// Note: updates when you rezise your screen (like on a browser or desktop window)
8 double get width => mediaQuerySize.width; 13 double get width => mediaQuerySize.width;
9 14
  15 + /// Gives you the power to get a portion of the height.
  16 + /// Useful for responsive applications.
  17 + ///
  18 + /// [dividedBy] is for when you want to have a portion of the value you would get
  19 + /// like for example: if you want a value that represents a third of the screen
  20 + /// you can set it to 3, and you will get a third of the height
  21 + ///
  22 + /// [reducedBy] is a percentage value of how much of the height you want
  23 + /// if you for example want 46% of the height, then you reduce it by 56%.
10 double heightTransformer({double dividedBy = 1, double reducedBy = 0.0}) { 24 double heightTransformer({double dividedBy = 1, double reducedBy = 0.0}) {
11 return (mediaQuerySize.height - 25 return (mediaQuerySize.height -
12 ((mediaQuerySize.height / 100) * reducedBy)) / 26 ((mediaQuerySize.height / 100) * reducedBy)) /
13 dividedBy; 27 dividedBy;
14 } 28 }
15 29
  30 + /// Gives you the power to get a portion of the width.
  31 + /// Useful for responsive applications.
  32 + ///
  33 + /// [dividedBy] is for when you want to have a portion of the value you would get
  34 + /// like for example: if you want a value that represents a third of the screen
  35 + /// you can set it to 3, and you will get a third of the width
  36 + ///
  37 + /// [reducedBy] is a percentage value of how much of the width you want
  38 + /// if you for example want 46% of the width, then you reduce it by 56%.
16 double widthTransformer({double dividedBy = 1, double reducedBy = 0.0}) { 39 double widthTransformer({double dividedBy = 1, double reducedBy = 0.0}) {
17 return (mediaQuerySize.width - ((mediaQuerySize.width / 100) * reducedBy)) / 40 return (mediaQuerySize.width - ((mediaQuerySize.width / 100) * reducedBy)) /
18 dividedBy; 41 dividedBy;
19 } 42 }
20 43
21 - double ratio(  
22 - {double dividedBy = 1, 44 + /// TODO: make docs about that
  45 + double ratio({
  46 + double dividedBy = 1,
23 double reducedByW = 0.0, 47 double reducedByW = 0.0,
24 - double reducedByH = 0.0}) { 48 + double reducedByH = 0.0,
  49 + }) {
25 return heightTransformer(dividedBy: dividedBy, reducedBy: reducedByH) / 50 return heightTransformer(dividedBy: dividedBy, reducedBy: reducedByH) /
26 widthTransformer(dividedBy: dividedBy, reducedBy: reducedByW); 51 widthTransformer(dividedBy: dividedBy, reducedBy: reducedByW);
27 } 52 }
28 53
29 - /// similar to MediaQuery.of(this).padding 54 + /// similar to [MediaQuery.of(context).padding]
30 EdgeInsets get mediaQueryPadding => MediaQuery.of(this).padding; 55 EdgeInsets get mediaQueryPadding => MediaQuery.of(this).padding;
31 56
32 - /// similar to MediaQuery.of(this).viewPadding 57 + /// similar to [MediaQuery.of(context).viewPadding]
33 EdgeInsets get mediaQueryViewPadding => MediaQuery.of(this).viewPadding; 58 EdgeInsets get mediaQueryViewPadding => MediaQuery.of(this).viewPadding;
34 59
35 - /// similar to MediaQuery.of(this).viewInsets; 60 + /// similar to [MediaQuery.of(context).viewInsets]
36 EdgeInsets get mediaQueryViewInsets => MediaQuery.of(this).viewInsets; 61 EdgeInsets get mediaQueryViewInsets => MediaQuery.of(this).viewInsets;
37 62
38 - /// similar to MediaQuery.of(this).orientation; 63 + /// similar to [MediaQuery.of(context).orientation]
39 Orientation get orientation => MediaQuery.of(this).orientation; 64 Orientation get orientation => MediaQuery.of(this).orientation;
40 65
41 /// check if device is on landscape mode 66 /// check if device is on landscape mode
@@ -44,10 +69,10 @@ extension MDQ on BuildContext { @@ -44,10 +69,10 @@ extension MDQ on BuildContext {
44 /// check if device is on portrait mode 69 /// check if device is on portrait mode
45 bool get isPortrait => orientation == Orientation.portrait; 70 bool get isPortrait => orientation == Orientation.portrait;
46 71
47 - /// similar to MediaQuery.of(this).devicePixelRatio; 72 + /// similar to [MediaQuery.of(this).devicePixelRatio]
48 double get devicePixelRatio => MediaQuery.of(this).devicePixelRatio; 73 double get devicePixelRatio => MediaQuery.of(this).devicePixelRatio;
49 74
50 - /// similar to MediaQuery.of(this).textScaleFactor; 75 + /// similar to [MediaQuery.of(this).textScaleFactor]
51 double get textScaleFactor => MediaQuery.of(this).textScaleFactor; 76 double get textScaleFactor => MediaQuery.of(this).textScaleFactor;
52 77
53 /// get the shortestSide from screen 78 /// get the shortestSide from screen