Posts

Showing posts from December, 2022

loading a local json file in flutter

Image
  import 'package:flutter/material.dart' ; import 'dart:convert' ; void main(){ runApp( MaterialApp ( home: HomePage (), theme: ThemeData ( primarySwatch: Colors. teal ), )); } class HomePage extends StatefulWidget { const HomePage({Key? key}) : super (key: key); @override State<HomePage> createState() => _HomePageState (); } class _HomePageState extends State<HomePage> { late List data ; @override Widget build(BuildContext context) { return Scaffold ( appBar: AppBar ( title: Text ( "Loading Json" ), ), body: Container ( child: Center ( child: FutureBuilder ( future: DefaultAssetBundle. of (context).loadString( 'load_jason/person.json' ), builder: (context,snapshot){ //Decoding json var myData = jsonDecode(snapshot. data .toString()); return ListView . builder ( itemBuilder: (Bu...

Creating a UI of Chat Application in flutter

Image
  import 'package:flutter/material.dart' ; void main() { runApp( MyApp ()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp (title: "Chat app" , home: HomePage ()); } } class HomePage extends StatelessWidget { const HomePage({Key? key}) : super (key: key); final String _name1 = "Sahnawaza" ; final String _name2 = "Altaf" ; final String _name3 = "Abhinav" ; final String _name4 = "Vivek" ; final String _name5 = "Mojahid" ; final String _name6 = "Shivam" ; final String _name7 = "Minshu" ; final String _name8 = "Ankush" ; final String _name9 = "Aryan" ; final String _name10 = "Ankit" ; final String _name11 = "Aditya" ; final String _name12 = "Raju" ; @override Widget build(BuildContext context) { return Scaffold ( // appBar: AppBar( // ti...

simple profile screen in flutter

import 'package:flutter/material.dart' ; void main() { runApp( MyApp ()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp ( title: "Chat app" , home: HomePage ()); } } class HomePage extends StatelessWidget { const HomePage({Key? key}) : super (key: key); @override Widget build(BuildContext context) { return Scaffold ( appBar: AppBar ( title: Text ( "Profile Screen" ), ), body: Container ( color: Colors. cyanAccent , height: double. infinity , width: double. infinity , child: Column ( mainAxisAlignment: MainAxisAlignment. start , children: [ Padding ( padding: const EdgeInsets . all ( 8.0 ), child: CircleAvatar ( radius: 70 , child: Text ( "M" ,style: TextStyle ( fontSize: 60 , f...

Creating a simple Arithmetical Calculator in Flutter

Image
  import 'package:flutter/cupertino.dart' ; import 'package:flutter/material.dart' ; // Import for Android features. void main() { runApp( MyApp ()); } //This is main homepage or we can say main body class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { Color color = Theme. of (context). primaryColor ; return MaterialApp ( title: 'Login Page' , home: MyHomePage (), ); } } class MyHomePage extends StatefulWidget { @override State<MyHomePage> createState() => _MyHomePageState (); } class _MyHomePageState extends State<MyHomePage> { var num1 = 0 , num2 = 0 , output = 0 ; final TextEditingController t1 = TextEditingController (text: "" ); final TextEditingController t2 = TextEditingController (text: "" ); void doAdd(){ setState(() { num1 = int. parse ( t1 . text ); num2 = int. parse ( t2 . text ); output = num1 + num2 ; }); } vo...

Creating a Login screen in Flutter

Image
  import 'package:flutter/cupertino.dart' ; import 'package:flutter/material.dart' ; // Import for Android features. void main() { runApp( MyApp ()); } //This is main homepage or we can say main body class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { Color color = Theme. of (context). primaryColor ; return MaterialApp ( title: 'Login Page' , home: MyHomePage (), ); } } class MyHomePage extends StatefulWidget { @override State<MyHomePage> createState() => _MyHomePageState (); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold ( appBar: AppBar ( title: Center ( child: Text ( 'Login Page' , style: TextStyle (fontWeight: FontWeight. bold ), )), ), body: Container ( decoration: BoxDecoration ( gradient...

making logic in flutter

  import 'package:flutter/cupertino.dart' ; import 'package:flutter/material.dart' ; // Import for Android features. void main() { runApp( MyApp ()); } //This is main homepage or we can say main body class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { Color color = Theme. of (context). primaryColor ; return MaterialApp ( title: 'Welcome to flutter' , home: MyHomePage (), ); } } class MyHomePage extends StatefulWidget { @override State<MyHomePage> createState() => _MyHomePageState (); } class _MyHomePageState extends State<MyHomePage> { String myText = "hello world" ; void changeState() { setState(() { if ( myText .startsWith( "h" )) { myText = "Welcome to flultter" ; } else { myText = "hello world" ; } }); } @override Widget build(BuildContext context) { return Scaffold ( appBa...

Creating a UI

Image
import 'package:flutter/cupertino.dart' ; import 'package:flutter/material.dart' ; void main() { runApp( MyApp ()); } // this is for button disign: Column _buttonBuildColumn(Color color, IconData icon, String label) { return Column ( mainAxisSize: MainAxisSize. min , mainAxisAlignment: MainAxisAlignment. center , children: [ Icon ( icon, color: color, ), Padding ( padding: const EdgeInsets . only (top: 8.0 ), child: Container ( child: Text ( label, style: TextStyle ( fontSize: 12 , fontWeight: FontWeight. w400 , color: color, ), ), ), ) ], ); } //this is for title section : Widget titleSection = Container ( padding: const EdgeInsets . all ( 32.0 ), child: Row ( children: [ Expanded ( child: Column ( crossAxisAlignment: CrossAxisAlignment. start ,...

Shared Preference - to store data locallyy

  import 'package:flutter/material.dart' ; import 'package:flutter/rendering.dart' ; import 'package:font_awesome_flutter/font_awesome_flutter.dart' ; import 'package:shared_preferences/shared_preferences.dart' ; import 'package:intl/intl.dart' ; import 'package:waris/IntroPage.dart' ; import 'package:waris/ProfileScreen.dart' ; //import 'package:waris/splash_screen.dart'; void main() { runApp( const MyApp ()); } class MyApp extends StatelessWidget { const MyApp({ super .key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp ( debugShowCheckedModeBanner: false , title: 'Flutter Demo' , theme: ThemeData ( textTheme: TextTheme ( headline1: TextStyle ( fontWeight: FontWeight. bold , fontSize: 25 , color: Colors. black ), subtitle1: TextStyle ( fontSize: 15 , ...

Mapping lists to widgets in flutter

  import 'package:flutter/material.dart' ; import 'package:flutter/rendering.dart' ; import 'package:font_awesome_flutter/font_awesome_flutter.dart' ; import 'package:intl/intl.dart' ; import 'package:waris/IntroPage.dart' ; import 'package:waris/ProfileScreen.dart' ; //import 'package:waris/splash_screen.dart'; void main() { runApp( const MyApp ()); } class MyApp extends StatelessWidget { const MyApp({ super .key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp ( debugShowCheckedModeBanner: false , title: 'Flutter Demo' , theme: ThemeData ( textTheme: TextTheme ( headline1: TextStyle ( fontWeight: FontWeight. bold , fontSize: 25 , color: Colors. black ), subtitle1: TextStyle ( fontSize: 15 , fontWeight: FontWeight. bold , color: ...