@@ -43,19 +43,11 @@ class ModelTest extends _ModelTest {
4343
4444 /// Constructs a new instance of [ModelTest]
4545 /// from optional and required parameters.
46- const ModelTest ({
47- this .users,
48- this .checks,
49- this .random,
50- });
46+ const ModelTest ({this .users, this .checks, this .random});
5147
5248 /// Construcs a new instance of [ModelTest] ,
5349 /// forcing all parameters to be optional.
54- const ModelTest .optional ({
55- this .users,
56- this .checks,
57- this .random,
58- });
50+ const ModelTest .optional ({this .users, this .checks, this .random});
5951
6052 /// Constructs a new instance of [ModelTest] ,
6153 /// and asserts that all required parameters are not null.
@@ -64,18 +56,12 @@ class ModelTest extends _ModelTest {
6456 List <int >? checks,
6557 Map <String , Map <dynamic , int >>? random,
6658 }) {
67- return ModelTest (
68- users: users,
69- checks: checks,
70- random: random,
71- );
59+ return ModelTest (users: users, checks: checks, random: random);
7260 }
7361
7462 /// Constructs a new instance of [ModelTest] ,
7563 /// from the fields of [another] instance. Throws if the conversion fails.
76- factory ModelTest .from (
77- BaseModel another,
78- ) {
64+ factory ModelTest .from (BaseModel another) {
7965 try {
8066 return fromOrNull (another)! ;
8167 } catch (e) {
@@ -88,17 +74,13 @@ class ModelTest extends _ModelTest {
8874 /// from the fields of [another] instance. Returns `null` if [another] is
8975 /// `null` or if the conversion fails.
9076 @pragma ('vm:prefer-inline' )
91- static ModelTest ? fromOrNull (
92- BaseModel ? another,
93- ) {
77+ static ModelTest ? fromOrNull (BaseModel ? another) {
9478 return fromJsonOrNull (another? .toJson ())! ;
9579 }
9680
9781 /// Constructs a new instance of [ModelTest] ,
9882 /// from the fields of [another] instance. Throws if the conversion fails.
99- factory ModelTest .of (
100- ModelTest another,
101- ) {
83+ factory ModelTest .of (ModelTest another) {
10284 try {
10385 return ofOrNull (another)! ;
10486 } catch (e) {
@@ -111,18 +93,14 @@ class ModelTest extends _ModelTest {
11193 /// from the fields of [another] instance. Returns `null` if [another] is
11294 /// `null` or if the conversion fails.
11395 @pragma ('vm:prefer-inline' )
114- static ModelTest ? ofOrNull (
115- ModelTest ? other,
116- ) {
96+ static ModelTest ? ofOrNull (ModelTest ? other) {
11797 return fromJsonOrNull (other? .toJson ());
11898 }
11999
120100 /// Constructs a new instance of [ModelTest] ,
121101 /// from [jsonString] , which must be a valid JSON String. Throws if the
122102 /// conversion fails.
123- factory ModelTest .fromJsonString (
124- String jsonString,
125- ) {
103+ factory ModelTest .fromJsonString (String jsonString) {
126104 try {
127105 return fromJsonStringOrNull (jsonString)! ;
128106 } catch (e) {
@@ -134,9 +112,7 @@ class ModelTest extends _ModelTest {
134112 /// Constructs a new instance of [ModelTest] ,
135113 /// from [jsonString] , which must be a valid JSON String. Returns `null` if
136114 /// [jsonString] is `null` or if the conversion fails.
137- static ModelTest ? fromJsonStringOrNull (
138- String ? jsonString,
139- ) {
115+ static ModelTest ? fromJsonStringOrNull (String ? jsonString) {
140116 try {
141117 if (jsonString! .isNotEmpty) {
142118 final decoded = letMapOrNull <String , dynamic >(jsonDecode (jsonString));
@@ -152,9 +128,7 @@ class ModelTest extends _ModelTest {
152128 /// Constructs a new instance of [ModelTest] ,
153129 /// from [json] , which must be a valid JSON object. Throws if the conversion
154130 /// fails.
155- factory ModelTest .fromJson (
156- Map <String , dynamic >? json,
157- ) {
131+ factory ModelTest .fromJson (Map <String , dynamic >? json) {
158132 try {
159133 return fromJsonOrNull (json)! ;
160134 } catch (e) {
@@ -166,9 +140,7 @@ class ModelTest extends _ModelTest {
166140 /// Constructs a new instance of [ModelTest] ,
167141 /// from [json] , which must be a valid JSON object. Returns `null` if
168142 /// [json] is `null` or if the conversion fails.
169- static ModelTest ? fromJsonOrNull (
170- Map <String , dynamic >? json,
171- ) {
143+ static ModelTest ? fromJsonOrNull (Map <String , dynamic >? json) {
172144 try {
173145 final users = letListOrNull <dynamic >(json? ['users' ])
174146 ? .map (
@@ -182,9 +154,7 @@ class ModelTest extends _ModelTest {
182154 ? .toList ()
183155 .unmodifiable;
184156 final checks = letListOrNull <dynamic >(json? ['checks' ])
185- ? .map (
186- (p0) => letAsOrNull <int >(p0),
187- )
157+ ? .map ((p0) => letAsOrNull <int >(p0))
188158 .nonNulls
189159 .nullIfEmpty
190160 ? .toList ()
@@ -194,12 +164,7 @@ class ModelTest extends _ModelTest {
194164 (p0, p1) => MapEntry (
195165 p0? .toString ().trim ().nullIfEmpty,
196166 letMapOrNull <dynamic , dynamic >(p1)
197- ? .map (
198- (p0, p1) => MapEntry (
199- p0,
200- letAsOrNull <int >(p1),
201- ),
202- )
167+ ? .map ((p0, p1) => MapEntry (p0, letAsOrNull <int >(p1)))
203168 .nonNulls
204169 .nullIfEmpty
205170 ? .unmodifiable,
@@ -208,11 +173,7 @@ class ModelTest extends _ModelTest {
208173 .nonNulls
209174 .nullIfEmpty
210175 ? .unmodifiable;
211- return ModelTest (
212- users: users,
213- checks: checks,
214- random: random,
215- );
176+ return ModelTest (users: users, checks: checks, random: random);
216177 } catch (e) {
217178 return null ;
218179 }
@@ -221,9 +182,7 @@ class ModelTest extends _ModelTest {
221182 /// Constructs a new instance of [ModelTest] ,
222183 /// from the query parameters of [uri] . Throws if the conversion
223184 /// fails.
224- factory ModelTest .fromUri (
225- Uri ? uri,
226- ) {
185+ factory ModelTest .fromUri (Uri ? uri) {
227186 try {
228187 return fromUriOrNull (uri)! ;
229188 } catch (e) {
@@ -235,9 +194,7 @@ class ModelTest extends _ModelTest {
235194 /// Constructs a new instance of [ModelTest] ,
236195 /// from the query parameters of [uri] . Returns `null` if [uri] is `null` or
237196 /// if the conversion fails.
238- static ModelTest ? fromUriOrNull (
239- Uri ? uri,
240- ) {
197+ static ModelTest ? fromUriOrNull (Uri ? uri) {
241198 try {
242199 if (uri != null && uri.path == CLASS_NAME ) {
243200 return ModelTest .fromJson (uri.queryParameters);
@@ -250,46 +207,24 @@ class ModelTest extends _ModelTest {
250207 }
251208
252209 @override
253- Map <String , dynamic > toJson ({
254- bool includeNulls = false ,
255- }) {
210+ Map <String , dynamic > toJson ({bool includeNulls = false }) {
256211 try {
257212 final users0 = users
258- ? .map (
259- (p0) => p0? .toJson (),
260- )
261- .nonNulls
262- .nullIfEmpty
263- ? .toList ();
264- final checks0 = checks
265- ? .map (
266- (p0) => p0,
267- )
213+ ? .map ((p0) => p0? .toJson ())
268214 .nonNulls
269215 .nullIfEmpty
270216 ? .toList ();
217+ final checks0 = checks? .map ((p0) => p0).nonNulls.nullIfEmpty? .toList ();
271218 final random0 = random
272219 ? .map (
273220 (p0, p1) => MapEntry (
274221 p0? .trim ().nullIfEmpty,
275- p1
276- ? .map (
277- (p0, p1) => MapEntry (
278- p0,
279- p1,
280- ),
281- )
282- .nonNulls
283- .nullIfEmpty,
222+ p1? .map ((p0, p1) => MapEntry (p0, p1)).nonNulls.nullIfEmpty,
284223 ),
285224 )
286225 .nonNulls
287226 .nullIfEmpty;
288- final withNulls = {
289- 'users' : users0,
290- 'random' : random0,
291- 'checks' : checks0,
292- };
227+ final withNulls = {'users' : users0, 'random' : random0, 'checks' : checks0};
293228 return includeNulls ? withNulls : withNulls.nonNulls;
294229 } catch (e) {
295230 assert (false , '$ModelTest .toJson: $e ' );
@@ -332,10 +267,7 @@ abstract final class ModelTestFieldNames {
332267extension ModelTestX on ModelTest {
333268 /// Creates a copy of this instance, merging another model's fields into
334269 /// this model's fields.
335- ModelTest mergeWith (
336- BaseModel ? other, {
337- bool deepMerge = false ,
338- }) {
270+ ModelTest mergeWith (BaseModel ? other, {bool deepMerge = false }) {
339271 final a = toJson ();
340272 final b = other? .toJson () ?? {};
341273 final data = (deepMerge ? mergeDataDeep (a, b) : {...a, ...b}) as Map ;
0 commit comments