@@ -110,21 +110,52 @@ Widget _defaultEmbedBuilder(
110
110
final style = node.style.attributes['style' ];
111
111
if (_isMobile () && style != null ) {
112
112
final _attrs = parseKeyValuePairs (style.value.toString (),
113
- {'mobileWidth' , 'mobileHeight' , 'mobileMargin' });
113
+ {'mobileWidth' , 'mobileHeight' , 'mobileMargin' , 'mobileAlignment' });
114
114
if (_attrs.isNotEmpty) {
115
- assert (_attrs.length == 3 ,
116
- 'mobileWidth, mobileHeight, mobileMargin must be specified' );
115
+ assert (
116
+ _attrs['mobileWidth' ] != null && _attrs['mobileHeight' ] != null ,
117
+ 'mobileWidth and mobileHeight must be specified' );
117
118
final w = double .parse (_attrs['mobileWidth' ]! );
118
119
final h = double .parse (_attrs['mobileHeight' ]! );
119
- final m = double .parse (_attrs['mobileMargin' ]! );
120
+ final m = _attrs['mobileMargin' ] == null
121
+ ? 0.0
122
+ : double .parse (_attrs['mobileMargin' ]! );
123
+ var a = Alignment .center;
124
+ if (_attrs['mobileAlignment' ] != null ) {
125
+ final _index = [
126
+ 'topLeft' ,
127
+ 'topCenter' ,
128
+ 'topRight' ,
129
+ 'centerLeft' ,
130
+ 'center' ,
131
+ 'centerRight' ,
132
+ 'bottomLeft' ,
133
+ 'bottomCenter' ,
134
+ 'bottomRight'
135
+ ].indexOf (_attrs['mobileAlignment' ]! );
136
+ if (_index >= 0 ) {
137
+ a = [
138
+ Alignment .topLeft,
139
+ Alignment .topCenter,
140
+ Alignment .topRight,
141
+ Alignment .centerLeft,
142
+ Alignment .center,
143
+ Alignment .centerRight,
144
+ Alignment .bottomLeft,
145
+ Alignment .bottomCenter,
146
+ Alignment .bottomRight
147
+ ][_index];
148
+ }
149
+ }
120
150
return Padding (
121
151
padding: EdgeInsets .all (m),
122
152
child: imageUrl.startsWith ('http' )
123
- ? Image .network (imageUrl, width: w, height: h)
153
+ ? Image .network (imageUrl, width: w, height: h, alignment : a )
124
154
: isBase64 (imageUrl)
125
155
? Image .memory (base64.decode (imageUrl),
126
- width: w, height: h)
127
- : Image .file (io.File (imageUrl), width: w, height: h));
156
+ width: w, height: h, alignment: a)
157
+ : Image .file (io.File (imageUrl),
158
+ width: w, height: h, alignment: a));
128
159
}
129
160
}
130
161
return imageUrl.startsWith ('http' )
0 commit comments