Example
We will see now code example for creating screen with “Hello GFG” label center in screen.
Dart
import 'package:flutter/material.dart' ; void main() { runApp(MyExampleApp()); } class MyExampleApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp(home: Scaffold(appBar: AppBar(title: Text( 'Flutter VS Java Example' ), ), body: Center(child: Text( 'Hello, GFG' , style: TextStyle(fontSize: 24)), ), ), ); } } |
Output:
Above example will create a screen with the title ‘Flutter VS Java‘ and label ‘Hello GFG’ title in screen center.
Java
import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView textView = findViewById(R.id.textView); textView.setText( "Hello, GFG" ); } } |
XML
<? xml version = "1.0" encoding = "utf-8" ?> < RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" > < TextView android:id = "@+id/textView" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_centerInParent = "true" android:textSize = "24sp" /> </ RelativeLayout > |
Output:
Above Example will display the default title with “Hello, GFG” label in center of the screen. You can notice here that for creating a single screen using Java you also need an XML file also which results in more development time.
Use Cases for Flutter:
- Cross-Platform Mobile Apps: Flutter would be the best choice for cross platform mobile application development. As with single code base you can write and deploy Android and iOS applications
- Rapid development. Flutter’s hot reload feature is suitable for startups and cases where projects require rapid development and frequent iteration needs. As developer can see the code changes very quickly
Use Cases for Java:
- Native Android App Development: For native Android app development java has been the primary programming language. It’s the best choice where requirements are native android specifically.
- Large Enterprise Applications: Large-scale enterprise applications like E-commerce, Banking, Medical Financial application Java would be more suitable then flutter.
Flutter vs Java
Here, we are going to discuss the two most popular technologies for making apps i.e. Flutter and Java. Imagine it like a showdown between two champs: Flutter and Java. No matter if you’re new to coding or a pro, we’ll check out what makes these languages tick. So without wasting any time let’s explore the strengths and weaknesses of both technologies together.
As we learn more about Flutter and Java, we’ll find out what they’re good at and where they might have a few tricks up their sleeves. But before jumping on the differences between the two let’s understand What is Flutter? and What is Java? So Let’s begin.
Contact Us