Android Basic App Code 

 

import ‘package:flutter/material.dart’;

void main()

{

runApp ( MyApp() );

}

class MyApp extends StatelessWidget

{

@override

Widget build(BuildContext context)

{        return Container();   }

}

—————————-Stateless Project——————————————-

import ‘package:flutter/material.dart’;

void main()

{

runApp ( MyApp() );

}

class MyApp extends StatelessWidget

{

@override

Widget build(BuildContext context)

{

return MaterialApp (

home: Text(“Venkat First Stateless App”);

);

}

}

 


 

—————————-Stateful Project——————————————-

import ‘package:flutter/material.dart’;

void main()

{

runApp(MyApp());

}

class MyApp extends StatefulWidget

{

@override

_State createState() => _State();

}

class _State extends State<MyApp> {

@override

Widget build(BuildContext context) {

return MaterialApp(

home: Column(

children: <Widget>[

Text(“Venkats First Stateful Project”),

FloatingActionButton ( child: Icon(Icons.access_time ),

)

],

),

);

}

}

—————————-Stateful Project with Events—————————————

import ‘package:flutter/material.dart’;

void main() {   runApp(MyApp());  }

class MyApp extends StatefulWidget {

@override

_State createState() => _State();

}

class _State extends State<MyApp> {

String value=”Venkat first Pjt”;

void clickMe()

{

setState(() {  value=”Venkat clicked val”;   });

}

@override

Widget build(BuildContext context) {

return MaterialApp(

home: Column(

children: <Widget>[

Text (“$value”),

FloatingActionButton ( child: Icon(Icons.access_time ),

onPressed: clickMe,

)

],

),

);

}

}

—————————-Stateful Project with Counter————————————-

import ‘package:flutter/material.dart’;

void main() {   runApp(MyApp());  }

class MyApp extends StatefulWidget {

@override

_State createState() => _State();

}

class _State extends State<MyApp> {

int counter=0;

void clickMe()

{

setState(() {   counter++;    });

}

@override

Widget build(BuildContext context) {

return MaterialApp(

home: Column(

children: <Widget>[

Text (“$counter”),

FloatingActionButton ( child: Icon(Icons.access_time ),

onPressed: clickMe,

)

],

),

);

}

}

——————————————————–

KaaShiv InfoTech Internship in Chennai Average rating: 5, based on 99876 reviews
× How can I help you?