API Reference 0.7.1rikulo_layoutAmountInfo

AmountInfo class

The dimension information specified in layout and profile.

Format: #n | content | flex | flex #n | #n %

class AmountInfo {
 AmountType type;
 num value;

 /** Constructor.
  */
 AmountInfo(String profile) {
   //no need to trim since it was trimmed
   if (profile == null || profile.isEmpty || profile == "none") {
     type = AmountType.NONE;
   } else if (profile == "content") {
     type = AmountType.CONTENT;
   } else if (profile == "ignore") {
     type = AmountType.IGNORE;
   } else if (profile.startsWith("flex")) {
     type = AmountType.FLEX;
     value = profile.length > 4 ? int.parse(profile.substring(4).trim()): 1;
     if (value < 1) value = 1;
   } else if (profile.endsWith("%")) {
     type = AmountType.RATIO;
     value= double.parse(profile.substring(0, profile.length - 1).trim()) / 100;
   } else {
     type = AmountType.FIXED;
     value = CssUtil.intOf(profile, reportError: true); //report error if no number at all
       //since it is common to end the number with px (because of CSS),
       //we retrieve only the number (and ignore the text following it).
   }
 }
 String toString() {
   return "$type:$value";
 }
}

Constructors

new AmountInfo(String profile) #

Constructor.

AmountInfo(String profile) {
 //no need to trim since it was trimmed
 if (profile == null || profile.isEmpty || profile == "none") {
   type = AmountType.NONE;
 } else if (profile == "content") {
   type = AmountType.CONTENT;
 } else if (profile == "ignore") {
   type = AmountType.IGNORE;
 } else if (profile.startsWith("flex")) {
   type = AmountType.FLEX;
   value = profile.length > 4 ? int.parse(profile.substring(4).trim()): 1;
   if (value < 1) value = 1;
 } else if (profile.endsWith("%")) {
   type = AmountType.RATIO;
   value= double.parse(profile.substring(0, profile.length - 1).trim()) / 100;
 } else {
   type = AmountType.FIXED;
   value = CssUtil.intOf(profile, reportError: true); //report error if no number at all
     //since it is common to end the number with px (because of CSS),
     //we retrieve only the number (and ignore the text following it).
 }
}

Properties

AmountType type #

AmountType type

num value #

num value

Methods

String toString() #

Returns a string representation of this object.

docs inherited from Object
String toString() {
 return "$type:$value";
}