22
33namespace Appwrite \SDK \Language ;
44
5- use Appwrite \SDK \Language ;
6-
7- class Flutter extends Language {
5+ class Flutter extends Dart {
86
97 /**
108 * @var array
@@ -13,17 +11,6 @@ class Flutter extends Language {
1311 'packageName ' => 'packageName ' ,
1412 ];
1513
16- /**
17- * @param string $name
18- * @return $this
19- */
20- public function setPackageName ($ name )
21- {
22- $ this ->setParam ('packageName ' , $ name );
23-
24- return $ this ;
25- }
26-
2714 /**
2815 * @return string
2916 */
@@ -32,219 +19,6 @@ public function getName()
3219 return 'Flutter ' ;
3320 }
3421
35- /**
36- * Get Language Keywords List
37- *
38- * @return array
39- */
40- public function getKeywords ()
41- {
42- return [
43- "abstract " ,
44- "dynamic " ,
45- "implements " ,
46- "show " ,
47- "as " ,
48- "else " ,
49- "import " ,
50- "static " ,
51- "assert " ,
52- "enum " ,
53- "in " ,
54- "super " ,
55- "async " ,
56- "export " ,
57- "interface " ,
58- "switch " ,
59- "await " ,
60- "extends " ,
61- "is " ,
62- "sync " ,
63- "break " ,
64- "external " ,
65- "library " ,
66- "this " ,
67- "case " ,
68- "factory " ,
69- "mixin " ,
70- "throw " ,
71- "catch " ,
72- "false " ,
73- "new " ,
74- "true " ,
75- "class " ,
76- "final " ,
77- "null " ,
78- "try " ,
79- "const " ,
80- "finally " ,
81- "on " ,
82- "typedef " ,
83- "continue " ,
84- "for " ,
85- "operator " ,
86- "var " ,
87- "covariant " ,
88- "Function " ,
89- "part " ,
90- "void " ,
91- "default " ,
92- "get " ,
93- "rethrow " ,
94- "while " ,
95- "deferred " ,
96- "hide " ,
97- "return " ,
98- "with " ,
99- "do " ,
100- "if " ,
101- "set " ,
102- "yield " ,
103- ];
104- }
105-
106- /**
107- * @param $type
108- * @return string
109- */
110- public function getTypeName ($ type )
111- {
112- switch ($ type ) {
113- case self ::TYPE_INTEGER :
114- return 'int ' ;
115- break ;
116- case self ::TYPE_STRING :
117- return 'String ' ;
118- break ;
119- case self ::TYPE_FILE :
120- return 'MultipartFile ' ;
121- break ;
122- case self ::TYPE_BOOLEAN :
123- return 'bool ' ;
124- break ;
125- case self ::TYPE_ARRAY :
126- return 'List ' ;
127- case self ::TYPE_OBJECT :
128- return 'dynamic ' ;
129- break ;
130- }
131-
132- return $ type ;
133- }
134-
135- /**
136- * @param array $param
137- * @return string
138- */
139- public function getParamDefault (array $ param )
140- {
141- $ type = $ param ['type ' ] ?? '' ;
142- $ default = $ param ['default ' ] ?? '' ;
143- $ required = $ param ['required ' ] ?? '' ;
144-
145- if ($ required ) {
146- return '' ;
147- }
148-
149- $ output = ' = ' ;
150-
151- if (empty ($ default ) && $ default !== 0 && $ default !== false ) {
152- switch ($ type ) {
153- case self ::TYPE_OBJECT :
154- $ output .= '{} ' ;
155- break ;
156- case self ::TYPE_NUMBER :
157- case self ::TYPE_INTEGER :
158- $ output .= '0 ' ;
159- break ;
160- case self ::TYPE_BOOLEAN :
161- $ output .= 'false ' ;
162- break ;
163- case self ::TYPE_ARRAY :
164- $ output .= '[] ' ;
165- break ;
166- case self ::TYPE_STRING :
167- $ output .= "'' " ;
168- break ;
169- }
170- }
171- else {
172- switch ($ type ) {
173- case self ::TYPE_OBJECT :
174- case self ::TYPE_NUMBER :
175- case self ::TYPE_INTEGER :
176- $ output .= $ default ;
177- break ;
178- case self ::TYPE_ARRAY :
179- $ output .= 'const ' .$ default ;
180- break ;
181- case self ::TYPE_BOOLEAN :
182- $ output .= ($ default ) ? 'true ' : 'false ' ;
183- break ;
184- case self ::TYPE_STRING :
185- $ output .= "' {$ default }' " ;
186- break ;
187- }
188- }
189-
190- return $ output ;
191- }
192-
193- /**
194- * @param array $param
195- * @return string
196- */
197- public function getParamExample (array $ param )
198- {
199- $ type = $ param ['type ' ] ?? '' ;
200- $ example = $ param ['example ' ] ?? '' ;
201-
202- $ output = '' ;
203-
204- if (empty ($ example ) && $ example !== 0 && $ example !== false ) {
205- switch ($ type ) {
206- case self ::TYPE_FILE :
207- $ output .= 'await MultipartFile.fromFile( \'./path-to-files/image.jpg \', \'image.jpg \') ' ;
208- break ;
209- case self ::TYPE_NUMBER :
210- case self ::TYPE_INTEGER :
211- $ output .= '0 ' ;
212- break ;
213- case self ::TYPE_BOOLEAN :
214- $ output .= 'false ' ;
215- break ;
216- case self ::TYPE_STRING :
217- $ output .= "'' " ;
218- break ;
219- case self ::TYPE_OBJECT :
220- $ output .= '{} ' ;
221- break ;
222- case self ::TYPE_ARRAY :
223- $ output .= '[] ' ;
224- break ;
225- }
226- }
227- else {
228- switch ($ type ) {
229- case self ::TYPE_OBJECT :
230- case self ::TYPE_FILE :
231- case self ::TYPE_NUMBER :
232- case self ::TYPE_INTEGER :
233- case self ::TYPE_ARRAY :
234- $ output .= $ example ;
235- break ;
236- case self ::TYPE_BOOLEAN :
237- $ output .= ($ example ) ? 'true ' : 'false ' ;
238- break ;
239- case self ::TYPE_STRING :
240- $ output .= "' {$ example }' " ;
241- break ;
242- }
243- }
244-
245- return $ output ;
246- }
247-
24822 /**
24923 * @return array
25024 */
@@ -320,4 +94,3 @@ public function getFiles()
32094 ];
32195 }
32296}
323-
0 commit comments