What's Flutter - Cross native platform to build Mobile applications
Easy to get started, perfect for hackathons, super fast to code!
Things you need to know before coming here -
print() function in any programming language
Getting started
This is just a guide to get you started. Flutter has amazing documentation with every widget explained in detail. Just walk through this repository, clone it, and try to see how the Widgets work. Once you feel comfortable with writing the basics, go on to some sample Apps and dive a little more. The next step after that should be to try new and different things with Flutter including Databases, Firebase, Machine learning, Animations and what not!
Do you know to code? language doesn't matter -> You can learn this really fast! You don't have to learn anything before this, just read the documentation and start making Apps
It's written in Dart which is very similar to JavaScript
Android Jetpack Compose, the latest way of Android app development is really similar to Flutter and I can see Android code being transformed to Flutter in the coming years. -> https://www.youtube.com/watch?v=dtm2h-_sNDQ
Firebase is definitely easier to implement for Flutter, you can do it in 20 lines of code depending on the list view you make
Android has crazy recycler views which make everything so hard, and integrating firebase + recycler view has about 200 articles, and you just cannot master it
Pushing data is also easier in Firebase, there's literally an onTap() method which allows you to send a snapshot of the data
Navigation - Flutter
Navigation is really easy, and if you know OOPS, then you'll master it in seconds
You just need to pass in the object and that's it. Pass it everywhere (literally!) - for the basics
Any data is passed in an Object which can be parsed in the next class
Firebase Functions - Notifications
Implemented fully optimized firebase functions and push notifications
The user is notified in real time when a new item is added to the recipes_list
Used Node JS and TypeScript to create a firebase function which does this
Tab Views - Android vs Flutter
Again, everything including this is very straightforward in Flutter
Make a Tab View, fill in the required parameters and you're all set
Tab Controller, TabBar for the Labels and TabBarView for the actual stuff in each tab
You could add literally any widget in there - Text, ListView etc
It's a bit more complex and well defined in Android
We need view pagers, adapters, and fragments to add a tab view
We can have different UIs for the fragments, but it's more time consuming to understand and implement
UI - Flutter vs React-Native vs Android
Android works with XML layouts, so that's in a separate file and much more readable in a sense
Flutter and RN have a one file system, where you define the rules and UI
Flutter uses Widgets for literally everything, from TextViews to TabViews - they're called 'Widgets'.
RN has components and we have to import them from 'react-native' to use them
Styling: Android - Using XML, Flutter - inside widgets - so if you want padding => you wrap the widget in Padding() widget with some padding, RN: you define const style: Stylesheet and add your styles there - similar to the web style where you have css
Animations: Android and RN is complicated for Animations, Flutter is very straightforward
Clean UI: All three can be used, but for static or single/simple pages - Android works out the fastest
What's the best? I would say all 3, so start learning ASAP
Computer vision ML integration
We can integrate a machine learning model to predict the food/recipe posted
We can probably look at a dataset of recipes and predict if it's going on the right path
Merging the ML code soon!
Different Code snippets -> Beginner - Intermediate - Advanced
fetch() async {
var url ="API-HERE";
var res =await http.get(url);
var body =jsonDecode(res.body);
// body is your API body
}
Parsing API - Eg: staggered tile
for(int i=0;i<body[0]['staggered_tiles'].length;i++){
_staggeredTiles.add(newStaggeredTile.count(
body[0]['staggered_tiles'][i]['cross_axis'],// body is what we get from the API
body[0]['staggered_tiles'][i]['main_axis']// body is what we get from the API
));
}
Parsing 2 APIs in one - Eg: pager view
if (body[i][0]['type'] =='donut') {
List<LabelPieSales> _d = [];
for (int j =0; j < body[i][0]['data'].length; j++) {
_d.add(newLabelPieSales(
body[i][0]['data'][j]['year'], body[i][0]['data'][j]['sales']));// body is what we get from the API
}
_wid_top.add(newContainer(
height:200,
width:200,
child:DonutChartWidget.withSampleData(_d),
));
}
elseif (body[i][0]['type'] =='label-pie') {
List<LabelPieSales> _d = [];
for (int j =0; j < body[i][0]['data'].length; j++) {
_d.add(newLabelPieSales(
body[i][0]['data'][j]['year'], body[i][0]['data'][j]['sales']));// body is what we get from the API
}
_wid_top.add(newContainer(
height:200,
width:200,
child:SimpleBarChart.withSampleData(_d),
));
}
API with Notifier - Eg: real time interaction with buttons and API
State management - Eg: adding new objects in SQL database
floatingActionButton:FloatingActionButton(
child:Icon(Icons.add),
onPressed: () async {
Dog dog =newDog(id: _id, name:"name",age:22);
awaitinsertDog(dog);
setState(() {
_id +=1;
});
},
),
Comparing SQL and API stuff - making a local push notification
List<Graph> graphs_sql =awaitgraphs();
List<String> graphs_sql_types = [];
for(int i=0;i<graphs_sql.length;i++){
graphs_sql_types.add(graphs_sql[i].type);
}
if (graphs_sql.length != _types.length) {
for (int i =0; i < _types.length; i++) {
if(!graphs_sql_types.contains(_types[i])){ // add only if a new typeawaitinsertGraph(newGraph(id: i, type: _types[i]));
}
}
}
Web views for Flutter - Eg: Displaying websites inside your app
Google Codelabs gave me the Asymmetric view, and I wanted to combine it with Firestore
It's definitely tricky as you can show data directly from the Firestore to a Listview, but it's a little tricky to store it and send the whole list to another class