You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`import function : imports the assets of the specified library from the pubspec.yaml file.
void main() : main function that runs first when the app is compiled every time.
class MyApp extends StatelessWidget {} : Contains a class (similar to java class) and creates a stateless widget.
@override : @override marks an instance member as overriding a superclass member with the same name.
build(BuildContext context) : BuildContext is a locator that is used to track each widget in a tree and locate them and their position in the tree. The BuildContext of each widget is passed to their build method.
Scaffold() : Scaffold is a class in flutter which provides many widgets or we can say APIs like Drawer, SnackBar, BottomNavigationBar etc.
body: : represents the body of the app , wrapped inside a scaffold , where several widgets can be used to layout a UI.
Center() : is a property to wrap around any widget and push the widget layout to be at the center of the screen/widget.
child: : It is a property of the parent widget that allows widgets to be put inside widgets , forming a widget tree.
Text() : It's a widget to pass in text to display it on the current screen.
import 'dart:convert' show json;
import 'package:http/http.dart' as http;
http.get(API_URL).then((http.Response res) {
final data = json.decode(res.body);
print(data);
});
Async Await
Future<int> doSmthAsync() async {
final result = await Future.value(42);
return result;
}
class SomeClass {
method() async {
final result = await Future.value(42);
return result;
}
}
JSON
import 'dart:convert' show json;
json.decode(someString);
json.encode(encodableObject);