├── AnimationRock.dart ├── AppBar_Animation.dart ├── Automatic Drag Drop.dart ├── Bloc.dart ├── Clipper.dart ├── Create new project ├── DateTime.dart ├── Designrock.dart ├── Firebase and http.dart ├── Firebase_admob.dart ├── FractionallySizedBox.dart ├── Future Function.dart ├── GetSet.dart ├── Git_Configs ├── Japaclub utils.dart ├── Jinsub_Kim.dart ├── Lazy_Loading.dart ├── Link lunchbox.html ├── Mac_1st_Running.dart ├── MaterialApp.dart ├── Multipart with dio.dart ├── Navigator_pushNamed.dart ├── Node_Configs ├── Notification guide.dart ├── OTP.dart ├── Open flutter dialog after navigation.dart ├── PhaseScriptExecution.dart ├── README.md ├── Row Fit.dart ├── ScopedModel.dart ├── Setup global path Mac.dart ├── SigningApk ├── SplashFullScreen ├── T t E e f .dart ├── TextField.dart ├── TextFormField.dart ├── android_manifest.dart ├── animatedIcon.dart ├── animation widget.dart ├── api_call.dart ├── app_install.dart ├── apple config.dart ├── auto_complete.dart ├── background fetch.kt ├── base64.dart ├── blackShodow.dart ├── blueprint.dart ├── card_with_black_shodow.dart ├── cicd.yml ├── custom_cluster.dart ├── datatable.dart ├── dependency_overrides.dart ├── developer1996.dart ├── dot effect.dart ├── drawer.dart ├── flaover.dart ├── flutter FAQ.xlsx ├── flutter2.0 ├── flutter_appLifeCycle.dart ├── flutter_launcher_icon.dart ├── future_builder.dart ├── game link.txt ├── getlastdayofmonth.dart ├── git branch ├── google_map_marker.dart ├── gradlefileerror.gradle ├── graphql setup.dart ├── handle_Red_error.dart ├── handshake expection.dart ├── heroku deploy.js ├── http.dart ├── https.dart ├── image_fadeout.dart ├── install_CocoaPods_without_sudo.md ├── ios_generate_ipa_file ├── layoutbuilder.dart ├── library.dart ├── listview_horizontal.dart ├── localNotification.dart ├── loginpage.dart ├── multipart http request.dart ├── native android.java ├── nfc check native.kt ├── notification_master.dart ├── null aware.dart ├── on navigate notification ├── play local audio.dart ├── portraitUp.dart ├── primarySwatch.dart ├── printing & pdf.dart ├── proguard-rules.pro ├── refreshfirebasetoken.dart ├── regex.dart ├── release.dart ├── rotate.dart ├── roundedAppBar ├── screenshot.dart ├── screenutil text.dar ├── searchFilter.dart ├── searchList.dart ├── setState in alert dialog.dart ├── setstate.dart ├── speechRec.dart ├── text recognize.dart ├── text with overflow.dart ├── timer.dart ├── vscode.extensions ├── web_flutter.dart ├── webview cookie set.dart ├── willpopscope.dart ├── wireless device connect └── youtube api integration /AnimationRock.dart: -------------------------------------------------------------------------------- 1 | //It's my first showcase of animation 2 | import 'dart:async'; 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:onprowork/screens/LoginPage.dart'; 6 | import 'package:onprowork/utils/Colors.dart'; 7 | 8 | class WelcomePage extends StatefulWidget { 9 | WelcomePage({Key key}) : super(key: key); 10 | 11 | _WelcomePageState createState() => _WelcomePageState(); 12 | } 13 | 14 | class _WelcomePageState extends State 15 | with SingleTickerProviderStateMixin { 16 | AnimationController _controller; 17 | Animation animation, delayedAnimation, muchDelayedAnimation, floatAnimation; 18 | 19 | 20 | @override 21 | void initState() { 22 | super.initState(); 23 | _controller = 24 | AnimationController(duration: Duration(seconds: 3), vsync: this); 25 | animation = Tween(begin: -1.0, end: 0.0).animate(CurvedAnimation( 26 | parent: _controller, 27 | curve: Curves.fastOutSlowIn, 28 | //reverseCurve: Curves.bounceIn 29 | )); 30 | delayedAnimation = Tween(begin: 1.0, end: 0.0).animate(CurvedAnimation( 31 | curve: Interval(0.5, 1.0, curve: Curves.easeOutSine), 32 | parent: _controller)); 33 | muchDelayedAnimation = Tween(begin: -1.0, end: 0.0).animate(CurvedAnimation( 34 | curve: Interval(0.5, 1.0, curve: Curves.easeOutSine), 35 | parent: _controller)); 36 | 37 | floatAnimation = Tween(begin: 1.0, end: 0.0).animate(CurvedAnimation( 38 | parent: _controller, 39 | curve: Interval(0.3, 0.5, curve: Curves.slowMiddle), 40 | )); 41 | _controller.forward(); 42 | } 43 | 44 | @override 45 | void dispose() { 46 | super.dispose(); 47 | 48 | _controller.dispose(); 49 | } 50 | 51 | @override 52 | Widget build(BuildContext context) { 53 | var mHeight = MediaQuery.of(context).size.height; 54 | var mWidth = MediaQuery.of(context).size.width; 55 | print(mHeight); 56 | print(mWidth); 57 | return AnimatedBuilder( 58 | animation: _controller, 59 | builder: (context, Widget w) { 60 | return SafeArea( 61 | child: Scaffold( 62 | backgroundColor: AppColors.colorBackground, 63 | body: Center( 64 | child: Column( 65 | mainAxisAlignment: MainAxisAlignment.center, 66 | crossAxisAlignment: CrossAxisAlignment.center, 67 | children: [ 68 | Transform( 69 | transform: Matrix4.translationValues( 70 | 0.0, animation.value * mWidth, 0.0), 71 | child: RichText( 72 | text: TextSpan( 73 | style: TextStyle( 74 | fontWeight: FontWeight.bold, 75 | color: Colors.white, 76 | fontSize: 35, 77 | ), 78 | children: [ 79 | TextSpan(text: "ONPRO"), 80 | TextSpan( 81 | text: "WORK", 82 | style: TextStyle( 83 | color: Color.fromRGBO(255, 71, 71, 1.0), 84 | ), 85 | ) 86 | ]), 87 | ), 88 | ), 89 | SizedBox( 90 | height: mHeight * 0.10, 91 | ), 92 | Transform( 93 | transform: Matrix4.translationValues( 94 | 0.0, -animation.value * mWidth, 0.0), 95 | child: Text( 96 | "Online Challenges Platform for Creative Designers and developers", 97 | textAlign: TextAlign.center, 98 | style: TextStyle( 99 | color: Colors.white, 100 | fontWeight: FontWeight.w300, 101 | fontSize: 20), 102 | ), 103 | ) 104 | ], 105 | ), 106 | )), 107 | ); 108 | }, 109 | ); 110 | } 111 | } 112 | ********************************************************************************************************************** 113 | -------------------------------------------------------------------------------- /AppBar_Animation.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:intl/intl.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class AppBarScreen extends StatefulWidget { 6 | AppBarScreen({Key key}) : super(key: key); 7 | 8 | @override 9 | _AppBarScreenState createState() => _AppBarScreenState(); 10 | } 11 | 12 | class _AppBarScreenState extends State { 13 | DateTime time = DateTime.now(); 14 | double height = 40, width = 150; 15 | final controller = ScrollController(); 16 | String abc = ""; 17 | int s = 0; 18 | @override 19 | void initState() { 20 | super.initState(); 21 | 22 | controller.addListener(onScroll); 23 | } 24 | 25 | onScroll() { 26 | setState(() { 27 | if (controller.offset >= 5) { 28 | print(controller.offset); 29 | height = 5; 30 | setState(() {}); 31 | } else if (controller.offset <= 20) { 32 | height = 40; 33 | setState(() {}); 34 | } 35 | }); 36 | } 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | return Scaffold( 41 | body: AnimatedBuilder( 42 | animation: controller, 43 | builder: (context, child) { 44 | return SafeArea( 45 | child: Stack( 46 | children: [ 47 | Scaffold( 48 | backgroundColor: Color.fromRGBO(14, 18, 49, 1.0), 49 | body: Padding( 50 | padding: const EdgeInsets.only(top: 20.0), 51 | child: ListView.builder( 52 | itemCount: 100, 53 | controller: controller, 54 | itemBuilder: (context, i) { 55 | return ListTile( 56 | title: Text( 57 | i.toString(), 58 | style: TextStyle(color: Colors.white), 59 | ), 60 | ); 61 | }, 62 | // List.generate( 63 | // 100, 64 | // (index) => ListTile( 65 | // title: Text(index.toString(),style: TextStyle(color: Colors.white),), 66 | // )), 67 | ), 68 | ), 69 | ), 70 | Container( 71 | height: 60, 72 | child: AppBar( 73 | backgroundColor: Color.fromRGBO(23, 46, 70, 1), 74 | title: Text('data'), 75 | ), 76 | ), 77 | AnimatedContainer( 78 | margin: EdgeInsets.zero, 79 | height: 100, 80 | alignment: Alignment.topCenter, 81 | padding: EdgeInsets.only(top: height), 82 | width: MediaQuery.of(context).size.width, 83 | duration: Duration(milliseconds: 200), 84 | child: Container( 85 | height: 50, 86 | margin: EdgeInsets.zero, 87 | width: 50, 88 | decoration: BoxDecoration( 89 | border: Border.all(color:height == 40? Color.fromRGBO(14, 18, 49, 1.0):Colors.transparent ,width:5, ), 90 | shape: BoxShape.circle, 91 | color: Colors.grey, 92 | image: DecorationImage( 93 | image: NetworkImage( 94 | "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQjjLHxsywm_DIt0UYfQv2KNudOzn_Wdqr05Ey6Xcuhrjlz7NDIwA&s"), 95 | 96 | ), 97 | ), 98 | child: Text(''), 99 | ), 100 | decoration: BoxDecoration( 101 | // color: Colors.amber, 102 | // shape: BoxShape.circle 103 | ), 104 | ) 105 | ], 106 | ), 107 | ); 108 | })); 109 | // return Scaffold( 110 | // appBar: AppBar( 111 | // title: Text('data'), 112 | 113 | // flexibleSpace: Stack( 114 | // overflow: Overflow.visible, 115 | // children: [ 116 | // // Text('data') 117 | // Container( 118 | // color: Colors.red, 119 | // padding: EdgeInsets.only(top: 150), 120 | // child: Text('data'), 121 | // ) 122 | // ], 123 | // ), 124 | // ), 125 | // body: AnimatedBuilder( 126 | // animation: controller, 127 | // builder: (context,child){ 128 | // return Stack( 129 | // alignment: Alignment.center, 130 | // children: [ 131 | 132 | // // Scaffold( 133 | // // backgroundColor: Colors.transparent, 134 | // // body:Padding( 135 | // // padding: const EdgeInsets.only(top:20.0), 136 | // // child: ListView( 137 | // // controller: controller, 138 | // // children: List.generate( 139 | // // 200, 140 | // // (index) => ListTile( 141 | // // title: Text(index.toString()), 142 | // // )), 143 | // // ), 144 | // // ), 145 | // // ), 146 | // Positioned( 147 | // top: 20, 148 | // // left: 50, 149 | // // right: 50, 150 | // child: AnimatedContainer( 151 | // width: width, 152 | // height: height, 153 | // decoration: BoxDecoration( 154 | // color: Colors.red, 155 | // // borderRadius: _borderRadius, 156 | // ), 157 | // duration: Duration(seconds: 1), 158 | // curve: Curves.fastOutSlowIn, 159 | // ), 160 | // ), 161 | // ], 162 | // );} 163 | // )); 164 | } 165 | } 166 | 167 | class BottomWaveClipper extends CustomClipper { 168 | @override 169 | Path getClip(Size size) { 170 | var path = new Path(); 171 | path.lineTo(0, size.height); 172 | var curXPos = 0.0; 173 | var curYPos = size.height; 174 | var increment = size.width / 20; 175 | while (curXPos < size.width) { 176 | curXPos += increment; 177 | path.arcToPoint(Offset(curXPos, curYPos), radius: Radius.circular(5)); 178 | } 179 | path.lineTo(size.width, 0); 180 | 181 | return path; 182 | } 183 | 184 | @override 185 | bool shouldReclip(CustomClipper oldClipper) => false; 186 | } 187 | -------------------------------------------------------------------------------- /Automatic Drag Drop.dart: -------------------------------------------------------------------------------- 1 | https://flutterstudio.app/ 2 | -------------------------------------------------------------------------------- /Bloc.dart: -------------------------------------------------------------------------------- 1 | https://github.com/viveky259259/flutter_for_people/tree/master/lib 2 | -------------------------------------------------------------------------------- /Clipper.dart: -------------------------------------------------------------------------------- 1 | https://iirokrankka.com/2017/09/04/clipping-widgets-with-bezier-curves-in-flutter/ 2 | https://github.com/roughike/wavy-image-mask/blob/master/lib/wavy_header_image.dart 3 | ************************************************************************************************************************ 4 | * * * 5 | * * * 6 | * * * 7 | class CustomShapeClipper extends CustomClipper { 8 | 9 | @override 10 | Path getClip(Size size) { 11 | final Path path = Path(); 12 | path.lineTo(0.0, size.height-20); 13 | var firstEndPoint = Offset(size.width*.5, size.height-35.0); 14 | var firstControlpoint = Offset(size.width*0.25, size.height-50.0); 15 | path.quadraticBezierTo(firstControlpoint.dx, firstControlpoint.dy, firstEndPoint.dx,firstEndPoint.dy); 16 | var secondEndpoint = Offset(size.width, size.height-80.0); 17 | var secondControlPoint = Offset(size.width *.75, size.height-10); 18 | path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy, secondEndpoint.dx,secondEndpoint.dy); 19 | path.lineTo(size.width,0.0); 20 | 21 | 22 | path.close(); 23 | return path; 24 | 25 | } 26 | 27 | @override 28 | bool shouldReclip(CustomClipper oldClipper) => true; 29 | } 30 | ************************************************************************************************************************ 31 | * 32 | * 33 | * 34 | * 35 | * 36 | * 37 | * 38 | * 39 | import 'package:flutter/material.dart'; 40 | 41 | class CustomShapeClipper extends CustomClipper { 42 | @override 43 | Path getClip(Size size) { 44 | final Path path = Path(); 45 | path.lineTo(0.0, size.height - 110); 46 | var secondEndpoint = Offset(size.width, size.height - 30.0); 47 | var secondControlPoint = Offset(size.width * .50, size.height - 30); 48 | path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy, 49 | secondEndpoint.dx, secondEndpoint.dy); 50 | path.lineTo(size.width, 0.0); 51 | 52 | path.close(); 53 | return path; 54 | } 55 | 56 | @override 57 | bool shouldReclip(CustomClipper oldClipper) => true; 58 | } 59 | 60 | class CustomShapeClipper2 extends CustomClipper { 61 | @override 62 | Path getClip(Size size) { 63 | final Path path = Path(); 64 | path.lineTo(0.0, size.height - 105); 65 | var secondEndpoint = Offset(size.width, size.height - 40.0); 66 | var secondControlPoint = Offset(size.width * .50, size.height - 30); 67 | path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy, 68 | secondEndpoint.dx, secondEndpoint.dy); 69 | path.lineTo(size.width, 0.0); 70 | 71 | path.close(); 72 | return path; 73 | } 74 | 75 | @override 76 | bool shouldReclip(CustomClipper oldClipper) => true; 77 | } 78 | *************************************************************************************************** 79 | //You can customize this clipper depend your requirement enjoy!! 80 | 81 | class InstaClipper2 extends CustomClipper { 82 | int a ,b; 83 | 84 | InstaClipper2({this.a,this.b}); 85 | 86 | 87 | @override 88 | Path getClip(Size size) { 89 | final Path path = Path(); 90 | path.lineTo(0.0, size.height - a); 91 | 92 | path.quadraticBezierTo(size.width - (size.width / 4), size.height - 30, 93 | size.width * 5, size.height - a); 94 | 95 | path.lineTo(size.width, 0.0); 96 | path.close(); 97 | return path; 98 | } 99 | 100 | @override 101 | bool shouldReclip(CustomClipper oldClipper) => true; 102 | } 103 | //You can use above class like below 104 | ClipPath( 105 | clipper: InstaClipper2(a: 190,b: 110), 106 | child: Container( 107 | decoration: BoxDecoration( 108 | color: Color(0xfff93B5B3), 109 | ), 110 | height: MediaQuery.of(context).size.height, 111 | width: double.infinity, 112 | ), 113 | ), 114 | ClipPath( 115 | clipper: InstaClipper2(a: 400,b: 200), 116 | child: Container( 117 | decoration: BoxDecoration( 118 | color: Color(0xfffC8DAD3), 119 | ), 120 | height: MediaQuery.of(context).size.height / 1.1, 121 | width: double.infinity, 122 | ), 123 | ), 124 | Positioned( 125 | right: 0, 126 | child: ClipPath( 127 | clipper: InstaClipper2(a: 900,b: 200), 128 | child: Container( 129 | decoration: BoxDecoration( 130 | color: Color(0xffF2F6F5), 131 | ), 132 | height: MediaQuery.of(context).size.height/1 , 133 | width: MediaQuery.of(context).size.width / 1.3, 134 | ), 135 | ), 136 | **************************************************************************************************************** 137 | * * 138 | * * 139 | * * 140 | * * 141 | class _MyClipper extends CustomClipper { 142 | @override 143 | Path getClip(Size size) { 144 | final path = Path(); 145 | path.lineTo(0, 0); 146 | path.lineTo(size.width, 0); 147 | path.lineTo(size.width, size.height * 0.8); 148 | path.lineTo(size.width * 0.8, size.height); 149 | path.lineTo(size.width * 0.2, size.height); 150 | path.lineTo(0, size.height * 0.8); 151 | path.lineTo(0, 0); 152 | 153 | path.close(); 154 | return path; 155 | } 156 | 157 | @override 158 | bool shouldReclip(CustomClipper oldClipper) => false; 159 | } 160 | -------------------------------------------------------------------------------- /Create new project: -------------------------------------------------------------------------------- 1 | flutter create --androidx --org com.example projectname 2 | -------------------------------------------------------------------------------- /DateTime.dart: -------------------------------------------------------------------------------- 1 | DateTime myDateTime = DateTime.now(); //2019-09-25 17:16:58.966855 2 | 3 | DateFormat.yMMMMd().format(myDateTime);//September 25, 2019 4 | DateFormat.yMMMd() .format(myDateTime);//Sep 25, 2019 5 | DateFormat.s().format(myDateTime); //58 6 | DateFormat.d() .format(myDateTime); //25 7 | DateFormat.E() .format(myDateTime); //Wed 8 | DateFormat.EEEE() .format(myDateTime); //Wednesday 9 | DateFormat.H() .format(myDateTime); //17 10 | DateFormat.Hm() .format(myDateTime); //17:16 11 | DateFormat.Hms() .format(myDateTime); //17:16:58 12 | DateFormat.jm().format(myDateTime); //5:16 PM 13 | DateFormat.j() .format(myDateTime); // 5 PM 14 | DateFormat.jms() .format(myDateTime); //5:16:58 PM 15 | DateFormat.MMM() .format(myDateTime); //Sep 16 | DateFormat.LLL() .format(myDateTime); //Sep 17 | DateFormat.MMMM() .format(myDateTime); //September 18 | DateFormat.LLLL() .format(myDateTime); //September 19 | DateFormat.MMMMd() .format(myDateTime); //September 25 20 | DateFormat.M() .format(myDateTime); //9 21 | DateFormat.m() .format(myDateTime); //16 22 | DateFormat.Md() .format(myDateTime); //9/25 23 | DateFormat.MEd() .format(myDateTime); //Wed, 9/25 24 | DateFormat.MMMd() .format(myDateTime); //Sep 25 25 | DateFormat.MMMEd() .format(myDateTime); //Wed, Sep 25 26 | DateFormat.MMMMEEEEd() .format(myDateTime); //Wednesday, September 25 27 | DateFormat.ms() .format(myDateTime); //16:58 28 | DateFormat.QQQ() .format(myDateTime); //Q3 29 | DateFormat.QQQQ() .format(myDateTime); //3rd quarter 30 | DateFormat.y() .format(myDateTime); //2019 31 | DateFormat.yM() .format(myDateTime); //9/2019 32 | DateFormat.yMd() .format(myDateTime); //9/25/2019 33 | DateFormat.yMEd().format(myDateTime); //Wed, 9/25/2019 34 | DateFormat.yMMM().format(myDateTime); //Sep 2019 35 | DateFormat.yMMMd().format(myDateTime); //Sep 25, 2019 36 | DateFormat.yMMMEd().format(myDateTime); // Wed, Sep 25, 2019 37 | DateFormat.yMMMM() .format(myDateTime); //September 2019 38 | DateFormat.yMMMMd() .format(myDateTime); //September 25, 2019 39 | DateFormat.yMMMMEEEEd() .format(myDateTime); //Wednesday, September 25, 2019 40 | DateFormat.yQQQ() .format(myDateTime); //Q3 2019 41 | DateFormat.yQQQQ() .format(myDateTime); //3rd quarter 2019 42 | -------------------------------------------------------------------------------- /Designrock.dart: -------------------------------------------------------------------------------- 1 | https://github.com/gskinnerTeam/flutter_vignettes 2 | https://flutter.gskinner.com/ 3 | https://www.youtube.com/watch?v=MI7Rl2umeeU 4 | -------------------------------------------------------------------------------- /Firebase and http.dart: -------------------------------------------------------------------------------- 1 | 2 | //for http 3 | await http.get("https://reqres.in/api/users?page=1").then((onValue) { 4 | var data = jsonEncode(onvalue.body); 5 | }); 6 | 7 | //for Firebase 8 | final messageReference = 9 | FirebaseDatabase.instance.reference().child('message_master'); 10 | -------------------------------------------------------------------------------- /FractionallySizedBox.dart: -------------------------------------------------------------------------------- 1 | Row( 2 | children: [ 3 | Flexible( 4 | fit: FlexFit.tight, 5 | flex: 5, 6 | child: FractionallySizedBox( 7 | widthFactor: 0.9, 8 | child: RaisedButton( 9 | child: Text("data"), 10 | onPressed: () {}, 11 | ), 12 | ), 13 | ), 14 | Flexible( 15 | fit: FlexFit.tight, 16 | flex: 5, 17 | child: FractionallySizedBox( 18 | widthFactor: 0.9, 19 | child: RaisedButton( 20 | child: Text("data"), 21 | onPressed: () {}, 22 | ), 23 | ), 24 | ), 25 | Flexible( 26 | fit: FlexFit.tight, 27 | flex: 5, 28 | child: FractionallySizedBox( 29 | widthFactor: 0.9, 30 | child: RaisedButton( 31 | child: Text("data"), 32 | onPressed: () {}, 33 | ), 34 | ), 35 | ), 36 | ], 37 | ) 38 | -------------------------------------------------------------------------------- /Future Function.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:convert'; 3 | 4 | import 'package:firebase_database/firebase_database.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:infilon_user/models/language_master_vo.dart'; 7 | import 'package:infilon_user/models/project_master_vo.dart'; 8 | import 'package:infilon_user/util/app_color.dart'; 9 | 10 | import 'package:infilon_user/util/app_image.dart'; 11 | import 'package:infilon_user/util/app_style.dart'; 12 | import 'package:shared_preferences/shared_preferences.dart'; 13 | 14 | class ProjectPage extends StatefulWidget { 15 | ProjectPage({Key key}) : super(key: key); 16 | 17 | _ProjectPageState createState() => _ProjectPageState(); 18 | } 19 | 20 | class _ProjectPageState extends State { 21 | String projectUserId; 22 | Future>> projectLangaugeData; 23 | final projectReference = 24 | FirebaseDatabase.instance.reference().child('project_master'); 25 | final languageReference = 26 | FirebaseDatabase.instance.reference().child('language_master'); 27 | AppStyle appStyle = AppStyle(); 28 | getUserId() async {} 29 | 30 | @override 31 | void initState() { 32 | super.initState(); 33 | getUserId(); 34 | projectLangaugeData = getProjectLanguageData(); 35 | } 36 | 37 | Future>> getProjectLanguageData() async { 38 | SharedPreferences pre = await SharedPreferences.getInstance(); 39 | if (projectUserId == null) { 40 | projectUserId = pre.getString("userId"); 41 | } 42 | List projectData = []; 43 | List languageData = []; 44 | return await projectReference 45 | .orderByChild("projectUserId") 46 | .equalTo(projectUserId) 47 | .once() 48 | .then((onValue) async { 49 | Map map = onValue.value; 50 | if (map != null) { 51 | for (var key in map.keys) { 52 | ProjectMasterVo pmv = ProjectMasterVo.fromJson(map[key], key: key); 53 | 54 | languageReference.child(pmv.projectLanguageId).once().then((onValue) { 55 | LanguageMasterVo lmv = 56 | LanguageMasterVo.fromJson(onValue.value, key: onValue.key); 57 | 58 | projectData.add(pmv); 59 | languageData.add(lmv); 60 | setState(() {}); 61 | }); 62 | } 63 | } 64 | return [ 65 | {"projectData": projectData}, 66 | {"languageData": languageData} 67 | ]; 68 | }); 69 | } 70 | 71 | @override 72 | Widget build(BuildContext context) { 73 | getUserId(); 74 | var width = MediaQuery.of(context).size.width; 75 | var height = MediaQuery.of(context).size.height; 76 | return getProjectBody(width, height); 77 | } 78 | 79 | Widget getProjectBody(double width, double height) { 80 | return FutureBuilder>>( 81 | future: projectLangaugeData.then((onValue) async => onValue), 82 | builder: (context, AsyncSnapshot>> snapshot) { 83 | if (snapshot.connectionState == ConnectionState.done) { 84 | if (snapshot.hasError) { 85 | return Container( 86 | child: Text("Something Went worng!"), 87 | ); 88 | } else { 89 | List projectData = 90 | snapshot.data[0]["projectData"]; 91 | List languageData = 92 | snapshot.data[1]["languageData"]; 93 | 94 | return projectData.isEmpty 95 | ? LinearProgressIndicator() 96 | : ListView.separated( 97 | itemCount: projectData.length, 98 | padding: EdgeInsets.symmetric( 99 | horizontal: width * 0.05, vertical: height * 0.03), 100 | separatorBuilder: (context, index) { 101 | return Divider(); 102 | }, 103 | itemBuilder: (context, index) { 104 | return Column( 105 | mainAxisAlignment: MainAxisAlignment.start, 106 | crossAxisAlignment: CrossAxisAlignment.start, 107 | children: [ 108 | SizedBox( 109 | height: height * 0.01, 110 | ), 111 | Text( 112 | projectData[index].projectName, 113 | style: appStyle.mediumTextStyle( 114 | color: AppColor.primarySwatch), 115 | ), 116 | SizedBox( 117 | height: 7, 118 | ), 119 | Row( 120 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 121 | children: [ 122 | Text( 123 | languageData[index].languageName, 124 | style: appStyle.smallTextStyle(), 125 | ), 126 | ImageIcon( 127 | AssetImage( 128 | AppImage.getImage( 129 | imagename: "doubleright.png"), 130 | ), 131 | size: 12, 132 | color: Colors.grey, 133 | ) 134 | ], 135 | ) 136 | ], 137 | ); 138 | }, 139 | ); 140 | } 141 | } else { 142 | return LinearProgressIndicator(); 143 | } 144 | }); 145 | } 146 | } 147 | // class FeedListState extends State { 148 | // // no idea how you named your data class... 149 | // Future> _listFuture; 150 | 151 | // @override 152 | // void initState() { 153 | // super.initState(); 154 | 155 | // // initial load 156 | // _listFuture = updateAndGetList(); 157 | // } 158 | 159 | // void refreshList() { 160 | // // reload 161 | // setState(() { 162 | // _listFuture = updateAndGetList(); 163 | // }); 164 | // } 165 | 166 | // Future> updateAndGetList() async { 167 | // await widget.feeds.update(); 168 | 169 | // // return the list here 170 | // return widget.feeds.getList(); 171 | // } 172 | 173 | // @override 174 | // Widget build(BuildContext context) { 175 | // return new FutureBuilder>( 176 | // future: _listFuture, 177 | // builder: (BuildContext context, AsyncSnapshot> snapshot) { 178 | // if (snapshot.connectionState == ConnectionState.waiting) { 179 | // return new Center( 180 | // child: new CircularProgressIndicator(), 181 | // ); 182 | // } else if (snapshot.hasError) { 183 | // return new Text('Error: ${snapshot.error}'); 184 | // } else { 185 | // final items = snapshot.data ?? []; // handle the case that data is null 186 | 187 | // return new Scrollbar( 188 | // child: new RefreshIndicator( 189 | // child: ListView.builder( 190 | // physics: const AlwaysScrollableScrollPhysics(), //Even if zero elements to update scroll 191 | // itemCount: items.length, 192 | // itemBuilder: (context, index) { 193 | // return FeedListItem(items[index]); 194 | // }, 195 | // ), 196 | // onRefresh: refreshList, 197 | // ), 198 | // ); 199 | // } 200 | // }, 201 | // ); 202 | // } 203 | // } 204 | -------------------------------------------------------------------------------- /GetSet.dart: -------------------------------------------------------------------------------- 1 | class LeaveHistoryData { 2 | String _status; 3 | String _date; 4 | String _comment; 5 | String _applied_time; 6 | String _reason; 7 | String _updated_time; 8 | 9 | LeaveHistoryData(this._status, this._date, this._comment, this._applied_time, 10 | this._reason, this._updated_time); 11 | 12 | LeaveHistoryData.map(dynamic obj) { 13 | this._status = obj["status"]; 14 | this._date = obj["date"]; 15 | this._comment = obj["comment"]; 16 | this._applied_time = obj["applied_time"]; 17 | this._reason = obj["reason"]; 18 | this._updated_time = obj["updated_time"]; 19 | } 20 | 21 | String get status => _status; 22 | String get date => _date; 23 | String get comment => _comment; 24 | String get applied_time => _applied_time; 25 | String get reason => _reason; 26 | String get updated_time => _updated_time; 27 | 28 | Map toMap() { 29 | var map = new Map(); 30 | map["status"] = _status; 31 | map["date"] = _date; 32 | map["comment"] = _comment; 33 | map["applied_time"] = _applied_time; 34 | map["reason"] = _reason; 35 | map["updated_time"] = _updated_time; 36 | 37 | return map; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Git_Configs: -------------------------------------------------------------------------------- 1 | git init 2 | git add README.md 3 | git commit -m "first commit" 4 | git remote add origin https://github.com/rbrinda029/MyProjects.git 5 | git push -u origin master 6 | -------------------------------------------------------------------------------- /Jinsub_Kim.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() => runApp(MyApp()); 4 | 5 | class MyApp extends StatelessWidget { 6 | // This widget is the root of your application. 7 | @override 8 | Widget build(BuildContext context) { 9 | return MaterialApp( 10 | title: 'Flutter Demo', 11 | theme: ThemeData( 12 | primaryColor: Colors.white, 13 | ), 14 | home: HomePage()); 15 | } 16 | } 17 | 18 | class HomePage extends StatefulWidget { 19 | @override 20 | _HomePageState createState() => _HomePageState(); 21 | } 22 | 23 | class _HomePageState extends State { 24 | List animalName = ["Lion", "Tiger", "Horse", "Pig", "Dog"]; 25 | List animalUrl = [ 26 | "lion.jpg", 27 | "tiger.jpg", 28 | "horse.jpg", 29 | "pig.jpg", 30 | "dog.jpg", 31 | ]; 32 | 33 | @override 34 | Widget build(BuildContext context) { 35 | return Scaffold( 36 | appBar: AppBar( 37 | centerTitle: true, 38 | title: Text('Animal List'), 39 | ), 40 | body: SafeArea( 41 | child: ListView.builder( 42 | itemCount: animalName.length, 43 | itemBuilder: (context, index) { 44 | return ListTile( 45 | title: Text(animalName[index]), 46 | onTap: () { 47 | Navigator.push( 48 | context, 49 | MaterialPageRoute( 50 | builder: (BuildContext context) => AnimalPage( 51 | animalUrl: animalUrl[index], 52 | title: animalName[index], 53 | text: "this is a ${animalName[index]}", 54 | )), 55 | ); 56 | }); 57 | }, 58 | ), 59 | ), 60 | ); 61 | } 62 | } 63 | 64 | class AnimalPage extends StatefulWidget { 65 | final String text, title, animalUrl; 66 | AnimalPage({this.title, this.text, this.animalUrl}); 67 | @override 68 | _AnimalPageState createState() => _AnimalPageState(); 69 | } 70 | 71 | class _AnimalPageState extends State { 72 | @override 73 | Widget build(BuildContext context) { 74 | return Scaffold( 75 | appBar: AppBar( 76 | title: Text(widget.title), 77 | ), 78 | body: Column(children: [ 79 | SizedBox( 80 | height: 200.0, 81 | width: 200.0, 82 | child: Image.asset( 83 | widget.animalUrl, 84 | )), 85 | Padding( 86 | padding: EdgeInsets.all(8.0), 87 | ), 88 | Wrap( 89 | children: [ 90 | Center( 91 | child: Text( 92 | widget.title, 93 | style: TextStyle(fontSize: 20.0), 94 | ), 95 | ) 96 | ], 97 | ) 98 | ]), 99 | ); 100 | } 101 | } 102 | 103 | 104 | -------------------------------------------------------------------------------- /Lazy_Loading.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase1/model.dart'; 2 | import 'package:firebase_database/firebase_database.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | final userDatabase = 6 | FirebaseDatabase.instance.reference().child("product_master"); 7 | 8 | class LazyLoad extends StatefulWidget { 9 | LazyLoad({Key key}) : super(key: key); 10 | 11 | _LazyLoadState createState() => _LazyLoadState(); 12 | } 13 | 14 | class _LazyLoadState extends State { 15 | int present = 0; 16 | int perPage = 10; 17 | List userList = List(); 18 | List items = List(); 19 | 20 | @override 21 | void initState() { 22 | super.initState(); 23 | 24 | userDatabase.once().then((DataSnapshot snapShot) { 25 | if (snapShot.value != null) { 26 | Map g = snapShot.value; 27 | for (dynamic k in g.keys) { 28 | userList.add(Posts.fromJson(g[k], key: k)); 29 | } 30 | setState(() { 31 | items.addAll(userList.getRange(present, present + perPage)); 32 | present = present + perPage; 33 | }); 34 | 35 | print(items.length); 36 | print(userList.length); 37 | } 38 | }); 39 | } 40 | 41 | Future getuser() async {} 42 | 43 | void loadMore() { 44 | setState(() { 45 | if ((present + perPage) > userList.length) { 46 | items.addAll(userList.getRange(present, userList.length)); 47 | } else { 48 | items.addAll(userList.getRange(present, present + perPage)); 49 | } 50 | present = present + perPage; 51 | }); 52 | } 53 | 54 | @override 55 | Widget build(BuildContext context) { 56 | return Scaffold( 57 | appBar: new AppBar( 58 | title: new Text('Lazy Load'), 59 | ), 60 | body: NotificationListener( 61 | onNotification: (ScrollNotification scrollInfo) { 62 | if (scrollInfo.metrics.pixels == 63 | scrollInfo.metrics.maxScrollExtent) { 64 | if (items.length != userList.length) { 65 | loadMore(); 66 | } 67 | } 68 | }, 69 | child: items.isNotEmpty 70 | ? ListView.builder( 71 | itemCount: (present <= userList.length) 72 | ? items.length + 1 73 | : items.length, 74 | itemBuilder: (context, index) { 75 | return (index == items.length) 76 | ? 77 | Container( 78 | color: Colors.greenAccent, 79 | child: FlatButton( 80 | child: Text("Load Mchhore"), 81 | onPressed: items.length != userList.length ?() { 82 | loadMore(); 83 | }:null 84 | ), 85 | ) 86 | : 87 | ListTile( 88 | title: Text(items[index].title), 89 | ), 90 | // (index == items.length ) ? Offstage() :CircularProgressIndicator(), 91 | }, 92 | ) 93 | : Offstage()), 94 | ); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Link lunchbox.html: -------------------------------------------------------------------------------- 1 | https://learnenglish.britishcouncil.org/online-english-level-test 2 | -------------------------------------------------------------------------------- /Mac_1st_Running.dart: -------------------------------------------------------------------------------- 1 | 1. Go to build Setting 2 | Flutter Application path 3 | /Users/infi_mini/Desktop/Yoshan-master // Write your project name instead of Yoshan-master 4 | 5 | 2. Flutter Root 6 | /Users/infi_mini/Desktop/Kartavya/Extra/flutter 7 | 8 | 3. Flutter target 9 | /Users/infi_mini/Desktop/Yoshan-master/lib/main.dart 10 | 11 | 4 Flutter framework dir 12 | /Users/infi_mini/Desktop/Kartavya/Extra/flutter/bin/cache/artifacts/engine/ios 13 | 14 | 15 | When you are transfer your project from somewhere 16 | 17 | then you should fire below command in root dir of that project 18 | # flutter packages get 19 | after that 20 | go to ios folder and open terminal 21 | 1. sudo gem install cocoapods 22 | 2. pod setup 23 | 3. pod init 24 | 4. pod install 25 | and when you have already pod file you want to update pod then fire below command 26 | 5. pod repo update 27 | Sorry for my weak english 28 | 29 | to remove existing pos file run below command: 30 | rm ios/Podfile 31 | -------------------------------------------------------------------------------- /MaterialApp.dart: -------------------------------------------------------------------------------- 1 | MaterialApp( 2 | theme: ThemeData( 3 | primarySwatch: Colors.deepOrange 4 | ), 5 | ); 6 | 7 | when you want to utilize this color somewhere else in your app then you can use like 8 | just instance: 9 | color:Theme.of(context).primaryColor 10 | -------------------------------------------------------------------------------- /Multipart with dio.dart: -------------------------------------------------------------------------------- 1 | FirebaseUser a = 2 | await FirebaseAuth.instance.currentUser(); 3 | var token = await a.getIdToken(refresh: true); 4 | Dio dio = new Dio(); 5 | FormData formData = new FormData(); 6 | formData.fields.add(MapEntry( 7 | "name", nameController.text.toString())); 8 | formData.fields.add(MapEntry( 9 | "email", emailController.text.toString())); 10 | formData.fields.add(MapEntry( 11 | "mobile", mobileController.text.toString())); 12 | formData.fields.add(MapEntry("address", 13 | addressController.text.toString())); 14 | formData.fields.add(MapEntry( 15 | "city", cityController.text.toString())); 16 | formData.fields.add(MapEntry( 17 | "mala_promise", dailyMalaPromise.toString())); 18 | formData.fields.add(MapEntry("reminder_interval", 19 | fixNullInt(count: intervalValue).toString())); 20 | 21 | if (image != null) { 22 | formData.files.add( 23 | MapEntry( 24 | "avatar", 25 | await MultipartFile.fromFile(image.path, 26 | filename: 27 | "demo ${image.path.toString().split(".").last}", 28 | contentType: MediaType("image", 29 | "${image.path.toString().split(".").last}")), 30 | ), 31 | ); 32 | } 33 | dio 34 | .post(signUpApi, 35 | data: formData, 36 | options: Options( 37 | method: 'POST', 38 | headers: { 39 | "Authorization": 40 | "Bearer ${token.token}", 41 | Headers.contentTypeHeader: 42 | "multipart/form-data" 43 | }, 44 | responseType: ResponseType 45 | .json // or ResponseType.JSON 46 | )) 47 | .then((r) { 48 | if (r.statusCode == 200) { 49 | String readRepositories = getProfile; 50 | doGraphQLAPICall( 51 | length: 50, 52 | httpURL: graphQl, 53 | queryData: readRepositories, 54 | ).then((result) { 55 | if (result["status"] == "success") { 56 | print(result.toString()); 57 | ProfileMaster profileMaster = 58 | ProfileMaster.fromJson( 59 | result["data"]["getProfile"]); 60 | 61 | pre.setString("profile", 62 | json.encode(profileMaster)); 63 | 64 | showToast(msg: "Successfully logged in"); 65 | Navigator.pushNamedAndRemoveUntil( 66 | context, 67 | AppConstant.homeRoute, 68 | ModalRoute.withName("/")); 69 | } 70 | }); 71 | } else { 72 | isLoading = false; 73 | setState(() {}); 74 | print(r); 75 | } 76 | }).catchError((print) { 77 | isLoading = false; 78 | setState(() {}); 79 | print(print); 80 | }); 81 | *********************************************************************************************************** 82 | // var uri = Uri.parse(productAddApi); 83 | // var request = http.MultipartRequest('POST', uri) 84 | // ..fields[keyName] = 'nweiz@google.com a' 85 | // ..fields[keyCategory] = 'nweiz@google.com' 86 | // ..fields[keyQuantity] = 'nweiz@google.com' 87 | // ..fields[keyUnit] = 'nweiz@google.com' 88 | // ..fields[keyPrice] = 'nweiz@google.com' 89 | // ..fields[keyDesc] = 'nweiz@google.com' 90 | // ..fields[keyStatus] = 'nweiz@google.com' 91 | // ..files.add(await http.MultipartFile.fromPath( 92 | // keyImage, _productAddUpdatePresenter.image.path, 93 | // contentType: new MediaType('image', 'jpeg'))); 94 | 95 | // var response = await request.send(); 96 | // print(response.reasonPhrase); 97 | // response.stream.transform(utf8.decoder).listen((value) { 98 | // print(value); 99 | // }); 100 | // if (response.statusCode == 200) print(response); 101 | 102 | FormData formData = FormData.fromMap({ 103 | keyName: _productAddUpdatePresenter.productName.text.trim(), 104 | keyCategory: _productAddUpdatePresenter.productCategory.value, 105 | keyQuantity: 106 | _productAddUpdatePresenter.productQuantity.text.trim(), 107 | keyUnit: _productAddUpdatePresenter.productUnit.value, 108 | keyPrice: _productAddUpdatePresenter.productPrice.text.trim(), 109 | keyDesc: _productAddUpdatePresenter.productDesc.text.trim(), 110 | keyStatus: _productAddUpdatePresenter.productStatus.value, 111 | keyImage: MultipartFile.fromFileSync( 112 | _productAddUpdatePresenter.image.path, 113 | contentType: new MediaType('image', 'jpeg') 114 | ) 115 | }); 116 | Dio() 117 | .post( 118 | productAddApi, 119 | data: formData, 120 | ) 121 | .then((value) => print(value.data)); 122 | -------------------------------------------------------------------------------- /Navigator_pushNamed.dart: -------------------------------------------------------------------------------- 1 | 2 | //main.dart 3 | 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:http/http.dart' as http; 7 | 8 | import 'package:flutter/foundation.dart' 9 | show debugDefaultTargetPlatformOverride; 10 | import 'package:jarvis/route_generator.dart'; 11 | 12 | import 'Jarvis.dart'; 13 | import 'database_helper_sqflite.dart'; 14 | 15 | void main() { 16 | debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; 17 | runApp(MyApp()); 18 | } 19 | 20 | class MyApp extends StatelessWidget { 21 | @override 22 | Widget build(BuildContext context) { 23 | return MaterialApp( 24 | debugShowCheckedModeBanner: false, 25 | title: 'Flutter Demo', 26 | theme: ThemeData( 27 | primarySwatch: Colors.blue, 28 | ), 29 | initialRoute: '/', 30 | onGenerateRoute: RouteGenerator.generateRoute, 31 | ); 32 | } 33 | } 34 | 35 | class FirstPage extends StatefulWidget { 36 | FirstPage({Key key}) : super(key: key); 37 | 38 | _FirstPageState createState() => _FirstPageState(); 39 | } 40 | 41 | class _FirstPageState extends State { 42 | @override 43 | Widget build(BuildContext context) { 44 | return Scaffold( 45 | appBar: AppBar( 46 | title: Text("First Page"), 47 | ), 48 | body: Center( 49 | child: RaisedButton( 50 | onPressed: () { 51 | Map abc = {"fname": "Aes", "lname": "Patel"}; 52 | Navigator.pushNamed(context, '/secondPage', arguments: abc); 53 | }, 54 | child: Text("Second Page"), 55 | ), 56 | ), 57 | ); 58 | } 59 | } 60 | 61 | class ThirdPage extends StatefulWidget { 62 | final Datum data; 63 | ThirdPage({this.data, Key key}) : super(key: key); 64 | 65 | _ThirdPageState createState() => _ThirdPageState(); 66 | } 67 | 68 | class _ThirdPageState extends State { 69 | @override 70 | Widget build(BuildContext context) { 71 | return Scaffold( 72 | appBar: AppBar(), 73 | body: Container( 74 | child: Column( 75 | children: [ 76 | Text(widget.data.avatar), 77 | Text(widget.data.email), 78 | Text(widget.data.firstName), 79 | Text(widget.data.lastName), 80 | Text(widget.data.id.toString()), 81 | ], 82 | ), 83 | ), 84 | ); 85 | } 86 | } 87 | 88 | class SecondPage extends StatefulWidget { 89 | final String fname; 90 | final String lname; 91 | SecondPage({this.lname, this.fname, Key key}) : super(key: key); 92 | 93 | _SecondPageState createState() => _SecondPageState(); 94 | } 95 | 96 | class _SecondPageState extends State { 97 | @override 98 | Widget build(BuildContext context) { 99 | return Scaffold( 100 | appBar: AppBar( 101 | title: Text("Second Page"), 102 | ), 103 | body: Column( 104 | children: [ 105 | Text( 106 | widget.fname + widget.lname, 107 | style: TextStyle(fontSize: 50), 108 | ), 109 | OutlineButton( 110 | child: Text("Third Page"), 111 | onPressed: () { 112 | Navigator.pushNamed(context, '/thirdPage', 113 | arguments: Datum( 114 | avatar: "jihdgksd;olgkjfdls;oak", 115 | email: "hdfjokdokgfddsf", 116 | id: 2, 117 | firstName: "hardik", 118 | lastName: "kumbhani")); 119 | }, 120 | ) 121 | ], 122 | ), 123 | ); 124 | } 125 | } 126 | 127 | //****************************************************************************************************************** 128 | 129 | //route_generator.dart 130 | 131 | import 'package:flutter/material.dart'; 132 | import 'package:jarvis/Jarvis.dart'; 133 | import 'main.dart'; 134 | 135 | class RouteGenerator { 136 | static Route generateRoute(RouteSettings settings) { 137 | final args = settings.arguments; 138 | switch (settings.name) { 139 | case '/': 140 | return MaterialPageRoute(builder: (_) => FirstPage()); 141 | case '/secondPage': 142 | if (args is Map) { 143 | return MaterialPageRoute( 144 | builder: (_) => SecondPage( 145 | fname: args["fname"], 146 | lname: args["lname"], 147 | )); 148 | } 149 | return _errorRoute(); 150 | case '/thirdPage': 151 | //remamber that Datum is PODO class 152 | if (args is Datum) { 153 | return MaterialPageRoute( 154 | builder: (_) => ThirdPage( 155 | data: args, 156 | )); 157 | } 158 | return _errorRoute(); 159 | default: 160 | return _errorRoute(); 161 | } 162 | } 163 | 164 | static Route _errorRoute() { 165 | return MaterialPageRoute(builder: (_) { 166 | return Scaffold( 167 | appBar: AppBar( 168 | title: Text("Error"), 169 | ), 170 | body: Center( 171 | child: Text("Error"), 172 | ), 173 | ); 174 | }); 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /Notification guide.dart: -------------------------------------------------------------------------------- 1 | https://medium.com/@duytq94/flutter-chat-app-extended-push-notification-messages-a26c669f4675 2 | https://backendless.com/developers/# 3 | check out above link for push notification 4 | There so many but like onesignal, IBM, Firebase, AWS push 5 | You can choose any one from them. 6 | -------------------------------------------------------------------------------- /OTP.dart: -------------------------------------------------------------------------------- 1 | PinFieldAutoFill( 2 | decoration: BoxLooseDecoration( 3 | solidColor: AppColors.white, 4 | strokeWidth: 3, 5 | strokeColor: Colors.grey, 6 | textStyle: AppStyle.mediumTextStyle()), 7 | // currentCode: '123456', // prefill with a code 8 | onCodeSubmitted: (String code) { 9 | Navigator.pushNamed(context, Constants.otpCompleteRoute); 10 | }, 11 | keyboardType: TextInputType.number, 12 | onCodeChanged: (String code) {}, 13 | codeLength: 6), 14 | 15 | lib: sms_autofill: ^1.1.1 16 | pin_input_text_field: ^2.1.0 17 | 18 | -------------------------------------------------------------------------------- /Open flutter dialog after navigation.dart: -------------------------------------------------------------------------------- 1 | @override 2 | void initState() { 3 | super.initState(); 4 | WidgetsBinding.instance.addPostFrameCallback((_) async { 5 | await showDialog( 6 | context: context, 7 | builder: (BuildContext context) => new AlertDialog( 8 | title: new Text("title"), 9 | content: new Text("Message"), 10 | actions: [ 11 | new FlatButton( 12 | child: new Text("OK"), 13 | onPressed: () { 14 | Navigator.of(context).pop(); 15 | }, 16 | ), 17 | ], 18 | ), 19 | ); 20 | }); 21 | } 22 | https://stackoverflow.com/questions/50806031/open-flutter-dialog-after-navigation 23 | -------------------------------------------------------------------------------- /PhaseScriptExecution.dart: -------------------------------------------------------------------------------- 1 | check it out this issue and try to slove problem you have to update your flutter root and flutter_application_path 2 | https://github.com/flutter/flutter/issues/17234 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter-lunchbox 2 | It's all about small small significant stuff 3 | --- 4 | Title: Flutter Interview Questions 5 | --- 6 | 7 | * What is the difference between a `StatelessWidget` and a `StatefulWidget` in Flutter? 8 | * Explain the Stateful Widget Lifecycle? 9 | * When do you use the `WidgetsBindingObserver`? 10 | * What is Flutter tree shaking? 11 | * What is a `Spacer` widget? 12 | * What is the difference between hot restart and hot reload? 13 | * What is an `InheritedWidget`? List some examples. 14 | * Why is the `build()` method on `State` and not `StatefulWidget`s? 15 | * What is a pubspec file in Dart? 16 | * How is Flutter native? 17 | * What is a `Navigator` and what are `Routes` in Flutter? 18 | * What is a `PageRoute`? 19 | * Explain `async`, `await` and `Future`s. 20 | * How can you update a `ListView` dynamically? 21 | * What is a `Stream`? 22 | * What are keys in Flutter and when should you use it? 23 | * What are `GlobalKeys`? 24 | * When should you use `mainAxisAlignment` and `crossAxisAlignment`? 25 | * When can you use `double.INFINITY`? 26 | * What is `Ticker`, `Tween` and `AnimatedBuilder`? 27 | * What is ephemeral state? 28 | * What is an `AspectRatio` widget used for? 29 | * How would you access `StatefulWidget` properties from its State? 30 | * Is there a suggested limit to the number of `FloatingActionButton`s a screen can have? Give a reason(s) for your answer 31 | * Mention two or more operations that would require you to use or return a Future. 32 | * What is the purpose of a `SafeArea`? 33 | * When to use a `mainAxisSize`? 34 | * SizedBox VS Container? 35 | * List the Visibility widgets in flutter and the differences? 36 | * Can we use Color and `Decoration` property simultaneously in the Container? Explain 37 | * Inorder for the CrossAxisAlignment.baseline to work what is another property that we need to set? 38 | * when should we use a `resizeToAvoidBottomInset`? 39 | * What is the difference between 'as','show' and 'hide' in an import statement? 40 | * What is the importance of a `TextEditingController`? 41 | * Why do we use a `Reverse` property in a Listview? 42 | * Difference between a `Modal` and `Persistent` BottomSheet with an example? 43 | * How is an Inherited Widget different from a Provider? 44 | * What is an `UnmodifiableListView`? 45 | * Difference between these operators "?? and ?." 46 | * What is the purpose of `ModalRoute.of()`? 47 | * Difference between a `Navigator.pushNamed` and `Navigator.pushReplacementNamed`? 48 | * Difference between a `Single Instance` and `Scoped Instance` ? 49 | 50 | 51 | Title: Animation Interview Questions 52 | --- 53 | 54 | * What is a `vsync`? 55 | * When does the animation reach `completed` or `dismissed` status? 56 | * Difference between `AnimationController and Animation? 57 | * When to use a `SingleTickerProviderStateMixin` and `TickerProviderStateMixin`? 58 | * Define a `TweenAnimation` ? 59 | * State the importance of a `Ticker` ? 60 | * Why do we need a `mixins` ? 61 | 62 | Title: FireStore Interview Questions 63 | --- 64 | 65 | * Difference between getDocuments() vs snapshots()? 66 | -------------------------------------------------------------------------------- /Row Fit.dart: -------------------------------------------------------------------------------- 1 | https://stackoverflow.com/questions/51326170/flutter-layout-row-column-share-width-expand-height 2 | IntrinsicHeight( 3 | child: Row( 4 | crossAxisAlignment: CrossAxisAlignment.stretch, 5 | -------------------------------------------------------------------------------- /ScopedModel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:responsive_grid/responsive_grid.dart'; 3 | import 'package:fl_chart/fl_chart.dart'; 4 | import 'package:scoped_model/scoped_model.dart'; 5 | import 'dart:async'; 6 | import 'package:speech_recognition/speech_recognition.dart'; 7 | 8 | class HelloMan extends StatefulWidget { 9 | HelloMan({Key key}) : super(key: key); 10 | 11 | _HelloManState createState() => _HelloManState(); 12 | } 13 | 14 | class _HelloManState extends State { 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return RotateMi(model: CounterModel()); 19 | 20 | } 21 | } 22 | 23 | 24 | 25 | class RotateMi extends StatefulWidget { 26 | final CounterModel model; 27 | RotateMi({this.model, Key key}) : super(key: key); 28 | 29 | _RotateMiState createState() => _RotateMiState(); 30 | } 31 | 32 | class _RotateMiState extends State { 33 | int _turns; 34 | double _value; 35 | double _x, _y, _z; 36 | int count = 0; 37 | bool df = false; 38 | @override 39 | void initState() { 40 | // TODO: implement initState 41 | super.initState(); 42 | _x = _y = _z = 0.0; 43 | } 44 | 45 | void _onChanged(double value) { 46 | setState(() { 47 | _turns = value.toInt(); 48 | _value = value; 49 | }); 50 | } 51 | 52 | final GlobalKey abc = GlobalKey(); 53 | @override 54 | Widget build(BuildContext context) { 55 | return ScopedModel( 56 | model: widget.model, 57 | child: MaterialApp( 58 | home: Scaffold( 59 | key: abc, 60 | floatingActionButton: FloatingActionButton( 61 | onPressed: () { 62 | setState(() { 63 | if (df) { 64 | df = false; 65 | } else { 66 | df = true; 67 | } 68 | 69 | abc.currentState.showBottomSheet((context) => df 70 | ? ScopedModelDescendant( 71 | builder: (context, child, model) { 72 | return Row( 73 | children: [ 74 | Text( 75 | model.counter.toString(), 76 | style: Theme.of(context).textTheme.display1, 77 | ), 78 | ScopedModelDescendant( 79 | builder: (context, child, model) { 80 | return RaisedButton(onPressed: model.zero); 81 | }), 82 | ], 83 | ); 84 | }, 85 | ) 86 | : Offstage()); 87 | }); 88 | }, 89 | ), 90 | 91 | body: Center( 92 | child: Column( 93 | mainAxisAlignment: MainAxisAlignment.center, 94 | children: [ 95 | ScopedModelDescendant( 96 | builder: (context, child, model) { 97 | return Text( 98 | model.counter.toString(), 99 | style: Theme.of(context).textTheme.display1, 100 | ); 101 | }, 102 | ), 103 | ScopedModelDescendant( 104 | builder: (context, child, model) { 105 | return RaisedButton(onPressed: model.increment); 106 | }), 107 | ], 108 | ), 109 | ), 110 | 111 | ), 112 | ), 113 | ); 114 | } 115 | } 116 | 117 | class CounterModel extends Model { 118 | int _counter = 0; 119 | 120 | int get counter => _counter; 121 | 122 | void increment() { 123 | // First, increment the counter 124 | _counter++; 125 | 126 | // Then notify all the listeners. 127 | notifyListeners(); 128 | } 129 | 130 | void zero() { 131 | _counter = 0; 132 | notifyListeners(); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /Setup global path Mac.dart: -------------------------------------------------------------------------------- 1 | open terminal 2 | =>1 nano ~/.bash_profile 3 | //When you are fire this command then you will get one notepad like screen in terminal and then you have to follow below command 4 | =>2 paste export PATH=$PATH://Users/iconflux/Documents/Flutter\ SDK/flutter/bin 5 | inside it and press ctrl + x and save that file 6 | =>3 after successfully doing above process 7 | fire this command in existing window 8 | source $HOME/.bash_profile 9 | =>4 now you can enjoy flutter anywhere in your mac os 10 | 11 | When you get non window file path error while building flutter tool then go to the packages/flutter_tool folder directory and fire below 12 | 13 | your_pc_path/flutter/bin/flutter 14 | 15 | 16 | 1. Open Terminal 17 | 2. Open Preferences 18 | 3. Go to profile Tab 19 | 4. Go to Shell Tab 20 | 5. And inside the startup run command please put => source $HOME/.bash_profile and check both checkbox true 21 | 6. Enjoy and cheers up 22 | 23 | *********************************************** 24 | When you don't get flutter cmd in your zsh terminal then please change terminal shell type to bash in android studio and which IDE you are using. 25 | -------------------------------------------------------------------------------- /SigningApk: -------------------------------------------------------------------------------- 1 | *************************************************************************************************************************************** 2 | 3 | => set label, icon and check appId. 4 | 5 | **************************************************************************************************************************************** 6 | => Create a keystore 7 | If you have an existing keystore, skip to the next step. If not, create one by running the following at the command line: 8 | 9 | On Mac/Linux, use the following command: 10 | 11 | content_copy 12 | keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key 13 | 14 | On Windows, use the following command: 15 | 16 | content_copy 17 | keytool -genkey -v -keystore c:/Users/USER_NAME/key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key 18 | 19 | or also you can generate keystore from android studio just open your flutter project android folder inside the android studio and wait till build 20 | not successed and then tap on BUILD and Generate signed bundle and apk and fill up all the thing 21 | 22 | **************************************************************************************************************************************** 23 | 24 | => key.properties 25 | 26 | - create key.properties folder inside android folder with following details: 27 | 28 | storePassword=flutter 29 | keyPassword=flutter 30 | keyAlias=AllUnitConverter 31 | storeFile=E:\Flutter\Infilon\all_unit_converter/allUnitConverterKey.jks 32 | 33 | **************************************************************************************************************************************** 34 | 35 | => changes to build.gradle file inside of your android/app folder. 36 | 37 | apply plugin: 'com.android.application' 38 | apply plugin: 'kotlin-android' 39 | apply plugin: 'io.fabric' 40 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 41 | 42 | def keystorePropertiesFile = rootProject.file("key.properties") 43 | def keystoreProperties = new Properties() 44 | keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) 45 | 46 | android { 47 | compileSdkVersion 28 48 | 49 | ***************************************************************************************************************************************** 50 | 51 | => Inside android {} make further changes for the release apk 52 | 53 | signingConfigs{ 54 | release{ 55 | keyAlias keystoreProperties['keyAlias'] 56 | keyPassword keystoreProperties['keyPassword'] 57 | storeFile file(keystoreProperties['storeFile']) 58 | storePassword keystoreProperties['storePassword'] 59 | } 60 | } 61 | 62 | buildTypes { 63 | release { 64 | // TODO: Add your own signing config for the release build. 65 | // Signing with the debug keys for now, so `flutter run --release` works. 66 | signingConfig signingConfigs.release 67 | } 68 | } 69 | 70 | ***************************************************************************************************************************************** 71 | => And finally on your command prompt 72 | 73 | flutter clean 74 | flutter build apk --release 75 | 76 | ***************************************************************************************************************************************** 77 | 78 | -------------------------------------------------------------------------------- /SplashFullScreen: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | 3 | @override 4 | void initState() { 5 | // To make this screen full screen. 6 | // It will hide status bar and notch. 7 | SystemChrome.setEnabledSystemUIOverlays([]); 8 | 9 | checkPermissions(); 10 | super.initState(); 11 | } 12 | 13 | @override 14 | void dispose() { 15 | super.dispose(); 16 | SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); 17 | 18 | // SystemChrome.setSystemUIOverlayStyle( 19 | // SystemUiOverlayStyle(statusBarColor: AppColor.colorPrimaryDark)); 20 | } 21 | -------------------------------------------------------------------------------- /T t E e f .dart: -------------------------------------------------------------------------------- 1 | main(List args) { 2 | DataHolder dataHolder = new DataHolder('Some data'); 3 | print(dataHolder.getData()); 4 | dataHolder.setData('New Data'); 5 | print(dataHolder.getData()); 6 | } 7 | 8 | class DataHolder { 9 | T data; 10 | 11 | DataHolder(this.data); 12 | 13 | getData() { 14 | return data; 15 | } 16 | 17 | setData(data) { 18 | this.data = data; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /TextField.dart: -------------------------------------------------------------------------------- 1 | // 11 Sep 2019 14:37 Pm 2 | Padding( 3 | padding: 4 | const EdgeInsets.symmetric(horizontal: 20, vertical: 20), 5 | child: TextField( 6 | style: TextStyle(fontFamily: "lora", color: Colors.black), 7 | decoration: new InputDecoration( 8 | hintText: 'Username', 9 | hintStyle: 10 | TextStyle(fontFamily: "lora", color: Colors.grey), 11 | prefixIcon: Icon( 12 | Icons.search, 13 | color: Colors.grey, 14 | ), 15 | filled: true, 16 | border: OutlineInputBorder( 17 | borderRadius: BorderRadius.circular(25)), 18 | enabledBorder: OutlineInputBorder( 19 | borderRadius: BorderRadius.circular(25), 20 | borderSide: const BorderSide( 21 | color: Color.fromRGBO(241, 241, 239, 1.0), 22 | width: 0.0), 23 | ), 24 | focusedBorder: OutlineInputBorder( 25 | borderRadius: BorderRadius.circular(25), 26 | borderSide: const BorderSide( 27 | color: Color.fromRGBO(241, 241, 239, 1.0), 28 | width: 0.0), 29 | ), 30 | fillColor: Color.fromRGBO(241, 241, 239, 1.0), 31 | ), 32 | 33 | ), 34 | ) 35 | -------------------------------------------------------------------------------- /TextFormField.dart: -------------------------------------------------------------------------------- 1 | TextFormField( 2 | style: TextStyle(color: Colors.white), 3 | obscureText: true, 4 | decoration: InputDecoration( 5 | prefixIcon: Align( 6 | alignment: Alignment(-1, 0), 7 | widthFactor: 0.0, 8 | child: Icon( 9 | Icons.security, 10 | color: Colors.white, 11 | ), 12 | ), 13 | 14 | hintText: "Enter Password", 15 | hintStyle: TextStyle(color: Colors.white), 16 | enabledBorder: UnderlineInputBorder( 17 | borderSide: BorderSide(color: Colors.white, width: 0.6), 18 | ), 19 | focusedBorder: UnderlineInputBorder( 20 | borderSide: 21 | BorderSide(color: AppColor.primarySwatch, width: 0.6), 22 | ), 23 | ), 24 | ), 25 | ******************************************************************************************** 26 | -------------------------------------------------------------------------------- /android_manifest.dart: -------------------------------------------------------------------------------- 1 | //If we wanna stop split mode then we should put this in android manifest file 2 | android:resizeableActivity="false" 3 | 4 | //pubspec.yaml 5 | firebase_core: 6 | firebase_database: 7 | firebase_auth: 8 | firebase_storage: 9 | firebase_messaging 10 | 11 | //build.gradle :- 12 | 13 | classpath 'com.android.tools.build:gradle:3.3.0' 14 | classpath 'com.google.gms:google-services:4.2.0' 15 | 16 | 17 | //gradle properties :- 18 | 19 | android.enableJetifier=true 20 | android.useAndroidX=true 21 | 22 | //build.gradle in app folder. 23 | 24 | 25 | dependencies { 26 | testImplementation 'junit:junit:4.12' 27 | androidTestImplementation 'androidx.test:runner:1.1.1' 28 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 29 | implementation 'com.google.firebase:firebase-core:16.0.9' 30 | implementation 'com.android.support:appcompat-v7:28.0.0' 31 | androidTestImplementation "com.android.support:support-annotations:28.0.0" 32 | } 33 | apply plugin: 'com.google.gms.google-services' 34 | 35 | 36 | // Status Bar hide 37 | 38 | @override 39 | void initState() { 40 | super.initState(); 41 | SystemChrome.setEnabledSystemUIOverlays([]); 42 | } 43 | 44 | // Status Bar Show 45 | 46 | @override 47 | void dispose() { 48 | // TODO: implement dispose 49 | super.dispose(); 50 | SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /animatedIcon.dart: -------------------------------------------------------------------------------- 1 | https://www.youtube.com/watch?v=sb92CI312oQ 2 | 3 | 4 | import 'package:flutter/material.dart'; 5 | 6 | 7 | class WheelExample extends StatefulWidget { 8 | @override 9 | _WheelExampleState createState() => _WheelExampleState(); 10 | } 11 | 12 | class _WheelExampleState extends State with SingleTickerProviderStateMixin{ 13 | int a; 14 | AnimationController anime; 15 | bool isplaying = true; 16 | 17 | @override 18 | void initState() { 19 | super.initState(); 20 | anime = AnimationController(duration: Duration(milliseconds: 600),vsync: this); 21 | 22 | } 23 | 24 | 25 | @override 26 | Widget build(BuildContext context) { 27 | return Scaffold( 28 | appBar: AppBar( 29 | title: Text('Wheel'), 30 | ), 31 | body: Center( 32 | child: GestureDetector( 33 | onTap: (){ 34 | anime.forward(); 35 | }, 36 | onDoubleTap: (){ 37 | anime.reverse(); 38 | }, 39 | child: Container( 40 | child: AnimatedIcon(icon: AnimatedIcons.arrow_menu,progress: anime,size: 45,), 41 | ), 42 | ), 43 | ), 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app_install.dart: -------------------------------------------------------------------------------- 1 | Future _downloadFile(String url, String filename) async { 2 | http.Client client = new http.Client(); 3 | var req = await client.get(Uri.parse(url)); 4 | var bytes = req.bodyBytes; 5 | 6 | String dir = (await getExternalStorageDirectory()).path; 7 | File file = new File('$dir/$filename'); 8 | await file.writeAsBytes(bytes).then((onValue) { 9 | // progressString = onValue 10 | if (file.path.isEmpty) { 11 | print('make sure the apk file is set'); 12 | return; 13 | } 14 | Map permissions = 15 | await PermissionHandler() 16 | .requestPermissions([PermissionGroup.storage]); 17 | if (permissions[PermissionGroup.storage] == PermissionStatus.granted) { 18 | InstallPlugin.installApk( 19 | file.path, 'com.botanical.botanical_garden_gandhinagar') 20 | .then((result) { 21 | print('install apk $result'); 22 | }).catchError((error) { 23 | print('install apk error: $error'); 24 | }); 25 | } else { 26 | print('Permission request fail!'); 27 | } 28 | }); 29 | 30 | 31 | 32 | return file; 33 | } 34 | -------------------------------------------------------------------------------- /apple config.dart: -------------------------------------------------------------------------------- 1 | 2 | 1. First of all we have to install pod in ios folder for run in ios device 3 | open ios folder from your project and open terminal 4 | => enter this command in termial 5 | $ sudo gem install cocoapods 6 | $ pod setup 7 | //make sure that you have already specify version of ios in your general file. 8 | 9 | 2. After that you have to refresh your xcode and build the app if there are something absence then you have to add into Podfile.lock 10 | Like example and repeat 1 step for get that package in pod 11 | pod "BSImagePicker", "~> 2.8" 12 | pod 'Firebase/Analytics' 13 | pod 'Firebase/Core' 14 | 15 | 3. moreever i got right now if your project with the firebase then you have to put googleService-info.plist in Runner directory 16 | 17 | and enjoy ios 18 | -------------------------------------------------------------------------------- /auto_complete.dart: -------------------------------------------------------------------------------- 1 | List plantList2 = []; 2 | AutoCompleteTextField searchTextField; 3 | GlobalKey> key = new GlobalKey(); 4 | 5 | bool loading = true; 6 | 7 | 8 | 9 | getData() async { 10 | await http 11 | .post(BaseApi.plant, body: json.encode({"lang": widget.languageKey})) 12 | .then((onValue) { 13 | var plantDat = json.decode(onValue.body); 14 | for (int i = 0; i < plantDat["data"].length; i++) { 15 | plantList2.add(PlantVo.fromJson(plantDat["data"][i])); 16 | } 17 | print(plantList2[0].title); 18 | setState(() {}); 19 | }); 20 | } 21 | 22 | @override 23 | void initState() { 24 | super.initState(); 25 | getData(); 26 | } 27 | 28 | 29 | 30 | Padding( 31 | padding: const EdgeInsets.all(20.0), 32 | child: AutoCompleteTextField( 33 | key: key, 34 | clearOnSubmit: true, 35 | suggestions: plantList2, 36 | style: AppStyle.largeTextStyle( 37 | fontFamily: widget.languageKey == "gu" 38 | ? AppStyle.primaryGuFontFamily 39 | : widget.languageKey == AppStyle.primaryHiFontFamily 40 | ? "Pragati" 41 | : AppStyle.primaryFontFamily), 42 | itemFilter: (item, query) { 43 | return item.title 44 | .toLowerCase() 45 | .startsWith(query.toLowerCase()); 46 | }, 47 | itemSorter: (a, b) { 48 | return a.title.compareTo(b.title); 49 | }, 50 | itemBuilder: (context, i) { 51 | print(i.id); 52 | return Column( 53 | children: [ 54 | ListTile( 55 | title: Text(i.title), 56 | onTap: () { 57 | Navigator.pushNamed( 58 | context, AppConstant.plantDetailRoute, 59 | arguments: { 60 | "languageKey": widget.languageKey, 61 | "plantKey": i.id 62 | }); 63 | }, 64 | ), 65 | // Text(i.title) 66 | ], 67 | ); 68 | }, 69 | decoration: InputDecoration( 70 | fillColor: AppColor.colorPrimary.withOpacity(0.0), 71 | enabledBorder: OutlineInputBorder( 72 | borderRadius: BorderRadius.circular(5), 73 | borderSide: BorderSide( 74 | color: AppColor.colorPrimary.shade100)), 75 | focusedBorder: OutlineInputBorder( 76 | borderRadius: BorderRadius.circular(5), 77 | borderSide: BorderSide( 78 | color: AppColor.colorPrimary.shade100)), 79 | filled: true, 80 | hintText: widget.labelKey["L12"][widget.languageKey] ?? 81 | widget.labelKey["L12"]["en"], 82 | // AppLocalizations.of(context).findyourplant, 83 | hintStyle: AppStyle.largeTextStyle( 84 | color: AppColor.colorPrimary, 85 | fontFamily: widget.languageKey == "gu" 86 | ? AppStyle.primaryGuFontFamily 87 | : widget.languageKey == 88 | AppStyle.primaryHiFontFamily 89 | ? "Pragati" 90 | : AppStyle.primaryFontFamily), 91 | 92 | // prefixIcon: Icon(Icons.search,color: AppColor.colorPrimary,), 93 | suffixIcon: IconButton( 94 | icon: Icon(Icons.search, color: AppColor.colorPrimary), 95 | onPressed: () { 96 | Navigator.pushNamed( 97 | context, AppConstant.plantListRoute, 98 | arguments: { 99 | "search": searchPlant.text, 100 | "languageKey": widget.languageKey, 101 | "labelKey": widget.labelKey 102 | }); 103 | }, 104 | ), 105 | border: OutlineInputBorder( 106 | borderRadius: BorderRadius.circular(12), 107 | borderSide: BorderSide.none, 108 | )), 109 | ), 110 | ), 111 | -------------------------------------------------------------------------------- /background fetch.kt: -------------------------------------------------------------------------------- 1 | https://github.com/transistorsoft/flutter_background_fetch/blob/master/help/INSTALL-ANDROID.md 2 | package com.example.localnoti 3 | 4 | import androidx.annotation.NonNull; 5 | import io.flutter.embedding.android.FlutterActivity 6 | import com.transistorsoft.flutter.backgroundfetch.BackgroundFetchPlugin; 7 | import io.flutter.embedding.engine.FlutterEngine 8 | 9 | import io.flutter.plugin.common.PluginRegistry; 10 | import io.flutter.plugins.GeneratedPluginRegistrant 11 | 12 | 13 | class MainActivity2: FlutterActivity() ,PluginRegistry.PluginRegistrantCallback { 14 | fun onCreate(){ 15 | BackgroundFetchPlugin.setPluginRegistrant(this); 16 | 17 | } 18 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 19 | GeneratedPluginRegistrant.registerWith(flutterEngine); 20 | } 21 | // override fun registerWith(registry: PluginRegistry) { 22 | // GeneratedPluginRegistrant.registerWith(this.flutterEngine); 23 | // } 24 | override fun registerWith(registry: PluginRegistry?) { 25 | registry?.registrarFor("com.transistorsoft.flutter.backgroundfetch.BackgroundFetchPlugin"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /base64.dart: -------------------------------------------------------------------------------- 1 | RaisedButton( 2 | onPressed: () async { 3 | List imageBytes = await sampleImage.readAsBytes(); 4 | base64Image = base64Encode(imageBytes); 5 | print(base64Image); 6 | }, 7 | ), 8 | SizedBox(height: 30,), 9 | Image.memory(base64Decode(base64Image)), 10 | 11 | -------------------------------------------------------------------------------- /blueprint.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/rendering.dart'; 2 | void main() { 3 | debugPaintBaselinesEnabled = true; 4 | debugPaintLayerBordersEnabled = true; 5 | debugRepaintRainbowEnabled = true; 6 | debugPaintSizeEnabled = true; 7 | debugPaintPointersEnabled = true; 8 | debugCheckElevationsEnabled = true; 9 | debugCheckIntrinsicSizes = true; 10 | debugDisableClipLayers = true; 11 | debugDisableOpacityLayers = true; 12 | debugDisablePhysicalShapeLayers = true; 13 | debugDisableShadows = true; 14 | 15 | runApp(MyApp());} 16 | -------------------------------------------------------------------------------- /card_with_black_shodow.dart: -------------------------------------------------------------------------------- 1 | _buildCard(String title, String rating, String imgPath) { 2 | return Padding( 3 | padding: EdgeInsets.all(10.0), 4 | child: InkWell( 5 | onTap: () { 6 | // Navigator.of(context) 7 | // .push(MaterialPageRoute(builder: (context) => DetailPage())); 8 | }, 9 | child: Stack( 10 | children: [ 11 | Container( 12 | height: 275.0, 13 | width: 200.0, 14 | decoration: BoxDecoration( 15 | borderRadius: BorderRadius.circular(20.0), 16 | image: DecorationImage( 17 | image: AssetImage(imgPath), fit: BoxFit.cover)), 18 | ), 19 | //make the shade a bit deeper. 20 | Container( 21 | height: 275.0, 22 | width: 200.0, 23 | decoration: BoxDecoration( 24 | borderRadius: BorderRadius.circular(20.0), 25 | color: Colors.black.withOpacity(0.4)), 26 | ), 27 | Positioned( 28 | top: 10.0, 29 | left: 10.0, 30 | child: Row( 31 | children: [ 32 | Container( 33 | height: 40.0, 34 | width: 60.0, 35 | decoration: BoxDecoration( 36 | borderRadius: BorderRadius.circular(20.0), 37 | color: Colors.black.withOpacity(0.2)), 38 | child: Center( 39 | child: Row( 40 | mainAxisAlignment: MainAxisAlignment.center, 41 | children: [ 42 | Icon(Icons.star, color: Colors.white, size: 12.0), 43 | SizedBox(width: 5.0), 44 | Text( 45 | rating, 46 | style: TextStyle(color: Colors.white), 47 | ) 48 | ], 49 | )), 50 | ), 51 | SizedBox(width: 50.0), 52 | Text( 53 | 'More', 54 | style: TextStyle( 55 | color: Colors.white, fontFamily: 'Opensans'), 56 | ), 57 | SizedBox(width: 7.0), 58 | //this should be an iconbutton in a real app. 59 | Icon(Icons.arrow_drop_down, color: Colors.white, size: 25.0) 60 | ], 61 | ), 62 | ), 63 | Positioned( 64 | top: 165.0, 65 | left: 10.0, 66 | child: Container( 67 | width: 150.0, 68 | child: Text(title, 69 | style: TextStyle( 70 | fontFamily: 'Opensans', 71 | fontSize: 17.0, 72 | color: Colors.white, 73 | fontWeight: FontWeight.w600)), 74 | ), 75 | ), 76 | Positioned( 77 | top: 225.0, 78 | left: 10.0, 79 | child: Row(children: [ 80 | Text('I was here', 81 | style: TextStyle( 82 | fontFamily: 'Opensans', 83 | fontSize: 15.0, 84 | color: Colors.white, 85 | fontWeight: FontWeight.w600)), 86 | SizedBox(width: 15.0), 87 | Stack( 88 | children: [ 89 | Container(height: 40.0, width: 100.0), 90 | Container( 91 | height: 40.0, 92 | width: 40.0, 93 | decoration: BoxDecoration( 94 | borderRadius: BorderRadius.circular(20.0), 95 | image: DecorationImage( 96 | image: AssetImage('assets/profilepic.jpg'), 97 | fit: BoxFit.cover)), 98 | ), 99 | Positioned( 100 | left: 30.0, 101 | child: Container( 102 | height: 40.0, 103 | width: 40.0, 104 | decoration: BoxDecoration( 105 | borderRadius: BorderRadius.circular(20.0), 106 | color: Colors.white), 107 | child: Center( 108 | child: Text('+17..', 109 | style: TextStyle( 110 | fontSize: 14.0, color: Colors.black)), 111 | ), 112 | ), 113 | ) 114 | ], 115 | ) 116 | ])) 117 | ], 118 | ), 119 | )); 120 | } 121 | -------------------------------------------------------------------------------- /cicd.yml: -------------------------------------------------------------------------------- 1 | Place inside 2 | base/.github/workflows/ci.yml 3 | *********************************** 4 | name: CI 5 | on: 6 | pull_request: 7 | branches: 8 | - main 9 | push: 10 | branches: 11 | - main 12 | 13 | jobs: 14 | flutter_test: 15 | name: Run flutter test and analyze 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v2 19 | - uses: actions/setup-java@v1 20 | with: 21 | java-version: "12.x" 22 | - uses: subosito/flutter-action@v1 23 | with: 24 | channel: "dev" 25 | - run: flutter pub get 26 | - run: flutter analyze 27 | - run: flutter test 28 | 29 | build_ios: 30 | name: Build Flutter (iOS) 31 | needs: [flutter_test] 32 | runs-on: macos-latest 33 | steps: 34 | - uses: actions/checkout@v2 35 | - uses: actions/setup-java@v1 36 | with: 37 | java-version: "12.x" 38 | - uses: subosito/flutter-action@v1 39 | with: 40 | channel: "dev" 41 | - run: flutter pub get 42 | - run: flutter clean 43 | - run: flutter build ios --release --no-codesign 44 | - name: Upload iOS APP 45 | uses: actions/upload-artifact@v2 46 | with: 47 | name: iOS APP 48 | path: ${{ github.workspace }}/build/ios/iphoneos/Runner.app 49 | 50 | build_web: 51 | name: Build Flutter (Web) 52 | needs: [flutter_test] 53 | runs-on: ubuntu-latest 54 | steps: 55 | - uses: actions/checkout@v2 56 | - uses: subosito/flutter-action@v1 57 | with: 58 | channel: beta 59 | - run: flutter config --enable-web 60 | - run: flutter pub get 61 | - run: flutter test 62 | - run: flutter build web 63 | 64 | build_appbundle: 65 | name: Build Flutter (Android) 66 | needs: [flutter_test] 67 | runs-on: ubuntu-latest 68 | steps: 69 | - uses: actions/checkout@v2 70 | - uses: actions/setup-java@v1 71 | with: 72 | java-version: "12.x" 73 | - uses: subosito/flutter-action@v1 74 | with: 75 | channel: "dev" 76 | - run: flutter pub get 77 | - run: flutter clean 78 | - run: flutter build apk 79 | - name: Upload APK 80 | uses: actions/upload-artifact@v2 81 | with: 82 | name: Andriod App 83 | path: ${{ github.workspace }}/build/app/outputs/apk/release/app-release.apk 84 | -------------------------------------------------------------------------------- /custom_cluster.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:convert'; 3 | import 'dart:typed_data'; 4 | import 'dart:ui'; 5 | import 'dart:ui' as ui show Image; 6 | import 'package:flutter/foundation.dart'; 7 | import 'package:flutter/gestures.dart'; 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter/services.dart'; 10 | ui.Image markerImage; 11 | ui.Image clusterMarkerImage; 12 | ByteData bytes = await rootBundle.load("assets/image.png"); 13 | markerImage = await decodeImageFromList( 14 | bytes.buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes)); 15 | 16 | ByteData bytes = await rootBundle.load("assets/cluster_image.png"); 17 | clusterMarkerImage = await decodeImageFromList( 18 | bytes.buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes)); 19 | 20 | 21 | Future _getCustomMarkerBitmap( 22 | {int clusterCount = 0, 23 | bool isCluster = true, 24 | int size}) async { 25 | 26 | /// Init the [Canvas] and [PictureRecorder] 27 | final PictureRecorder pictureRecorder = PictureRecorder(); 28 | final Canvas canvas = Canvas(pictureRecorder); 29 | final Paint paint1 = Paint() 30 | ..style = PaintingStyle.stroke; 31 | 32 | /// condition for marker background image 33 | ui.Image markerImage; 34 | if (isCluster) { 35 | markerImage = clusterMarkerImage; 36 | } else { 37 | markerImage = markerImage; 38 | } 39 | /// For management of image marker with Rect 40 | final Size imageSize = Size(markerImage.width.toDouble(), markerImage.height.toDouble()); 41 | final Rect src = Offset.zero & imageSize; 42 | final Rect dst = Offset.zero & const Size(125, 100); 43 | canvas.drawImageRect(markerImage, src, dst, paint1..blendMode = BlendMode.colorBurn); 44 | 45 | /// condition for marker text 46 | String markerText = ''; 47 | if (isCluster) { 48 | markerText = clusterCount.toString(); 49 | } else 50 | markerText = "hello flutter"; 51 | } 52 | 53 | /// For the render text string in marker 54 | final TextPainter painter = TextPainter(textDirection: TextDirection.ltr); 55 | painter.text = TextSpan( 56 | text: markerText, 57 | style: TextStyle(fontSize: size / 3.9, color: Palette.black, fontWeight: FontWeight.w700, fontFamily: 'Lato'), 58 | ); 59 | painter.layout(); 60 | painter.paint(canvas, Offset(size / 1.550 - painter.width / 2.22, size / 1.950 - painter.height / 0.80)); 61 | 62 | /// For the convert canvas to [ui.Image] 63 | final ui.Image img = await pictureRecorder.endRecording().toImage(size, size); 64 | final ByteData data = await img.toByteData(format: ImageByteFormat.png); 65 | 66 | /// return BitmapDescriptor of marker 67 | return BitmapDescriptor.fromBytes(data.buffer.asUint8List()); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /datatable.dart: -------------------------------------------------------------------------------- 1 | class CustomDataTable extends StatefulWidget { 2 | final T fixedCornerCell; 3 | final List fixedColCells; 4 | final List fixedRowCells; 5 | final List> rowsCells; 6 | final Widget Function(T data) cellBuilder; 7 | final double fixedColWidth; 8 | final double cellWidth; 9 | final double cellHeight; 10 | final double cellMargin; 11 | final double cellSpacing; 12 | 13 | CustomDataTable({ 14 | this.fixedCornerCell, 15 | this.fixedColCells, 16 | this.fixedRowCells, 17 | @required this.rowsCells, 18 | this.cellBuilder, 19 | this.fixedColWidth = 60.0, 20 | this.cellHeight = 56.0, 21 | this.cellWidth = 120.0, 22 | this.cellMargin = 10.0, 23 | this.cellSpacing = 10.0, 24 | }); 25 | 26 | @override 27 | State createState() => CustomDataTableState(); 28 | } 29 | 30 | class CustomDataTableState extends State> { 31 | final _columnController = ScrollController(); 32 | final _rowController = ScrollController(); 33 | final _subTableYController = ScrollController(); 34 | final _subTableXController = ScrollController(); 35 | 36 | Widget _buildChild(double width, T data) => SizedBox( 37 | width: width, child: widget.cellBuilder?.call(data) ?? Text('$data')); 38 | 39 | Widget _buildFixedCol() => widget.fixedColCells == null 40 | ? SizedBox.shrink() 41 | : Material( 42 | color: AppColor.primarySwatch.withOpacity(0.5), 43 | child: DataTable( 44 | horizontalMargin: widget.cellMargin, 45 | columnSpacing: widget.cellSpacing, 46 | headingRowHeight: widget.cellHeight, 47 | dataRowHeight: widget.cellHeight, 48 | columns: [ 49 | DataColumn( 50 | label: _buildChild( 51 | widget.fixedColWidth, widget.fixedColCells.first)) 52 | ], 53 | rows: widget.fixedColCells 54 | .sublist(widget.fixedRowCells == null ? 1 : 0) 55 | .map((c) => DataRow( 56 | cells: [DataCell(_buildChild(widget.fixedColWidth, c))])) 57 | .toList()), 58 | ); 59 | 60 | Widget _buildFixedRow() => widget.fixedRowCells == null 61 | ? SizedBox.shrink() 62 | : Material( 63 | color: AppColor.secondColor, 64 | child: DataTable( 65 | horizontalMargin: widget.cellMargin, 66 | columnSpacing: widget.cellSpacing, 67 | headingRowHeight: widget.cellHeight, 68 | dataRowHeight: widget.cellHeight, 69 | columns: widget.fixedRowCells 70 | .map((c) => 71 | DataColumn(label: _buildChild(widget.cellWidth, c))) 72 | .toList(), 73 | rows: []), 74 | ); 75 | 76 | Widget _buildSubTable() => Material( 77 | color: AppColor.primarySwatch.shade100, 78 | child: DataTable( 79 | horizontalMargin: widget.cellMargin, 80 | columnSpacing: widget.cellSpacing, 81 | headingRowHeight: widget.cellHeight, 82 | dataRowHeight: widget.cellHeight, 83 | columns: widget.rowsCells.first 84 | .map((c) => DataColumn(label: _buildChild(widget.cellWidth, c))) 85 | .toList(), 86 | rows: widget.rowsCells 87 | .sublist(widget.fixedRowCells == null ? 1 : 0) 88 | .map((row) => DataRow( 89 | cells: row 90 | .map((c) => DataCell(_buildChild(widget.cellWidth, c))) 91 | .toList())) 92 | .toList())); 93 | 94 | Widget _buildCornerCell() => 95 | widget.fixedColCells == null || widget.fixedRowCells == null 96 | ? SizedBox.shrink() 97 | : Material( 98 | color: AppColor.secondColor, 99 | child: DataTable( 100 | horizontalMargin: widget.cellMargin, 101 | columnSpacing: widget.cellSpacing, 102 | headingRowHeight: widget.cellHeight, 103 | dataRowHeight: widget.cellHeight, 104 | columns: [ 105 | DataColumn( 106 | label: _buildChild( 107 | widget.fixedColWidth, widget.fixedCornerCell)) 108 | ], 109 | rows: []), 110 | ); 111 | 112 | @override 113 | void initState() { 114 | super.initState(); 115 | _subTableXController.addListener(() { 116 | _rowController.jumpTo(_subTableXController.position.pixels); 117 | }); 118 | _subTableYController.addListener(() { 119 | _columnController.jumpTo(_subTableYController.position.pixels); 120 | }); 121 | } 122 | 123 | @override 124 | Widget build(BuildContext context) { 125 | return Stack( 126 | children: [ 127 | Row( 128 | children: [ 129 | SingleChildScrollView( 130 | controller: _columnController, 131 | scrollDirection: Axis.vertical, 132 | physics: NeverScrollableScrollPhysics(), 133 | child: _buildFixedCol(), 134 | ), 135 | Flexible( 136 | child: SingleChildScrollView( 137 | controller: _subTableXController, 138 | scrollDirection: Axis.horizontal, 139 | child: SingleChildScrollView( 140 | controller: _subTableYController, 141 | scrollDirection: Axis.vertical, 142 | child: _buildSubTable(), 143 | ), 144 | ), 145 | ), 146 | ], 147 | ), 148 | Row( 149 | children: [ 150 | _buildCornerCell(), 151 | Flexible( 152 | child: SingleChildScrollView( 153 | controller: _rowController, 154 | scrollDirection: Axis.horizontal, 155 | physics: NeverScrollableScrollPhysics(), 156 | child: _buildFixedRow(), 157 | ), 158 | ), 159 | ], 160 | ), 161 | ], 162 | ); 163 | } 164 | } 165 | final _rowsCells = [ 166 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 167 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 168 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 169 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 170 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 171 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 172 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 173 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 174 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 175 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 176 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 177 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 178 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 179 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 180 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 181 | ["18:23", "NA", "18:23", "On", "NA", "18:23", "NA", "-", "-", "-"], 182 | 183 | ]; 184 | final _fixedColCells = [ 185 | "Porridge", 186 | "Eggs", 187 | "Milk", 188 | "Other", 189 | "Main meat", 190 | "Vitamised", 191 | "Vegetables ", 192 | "Soup", 193 | "Porridge", 194 | "Eggs", 195 | "Milk", 196 | "Other", 197 | "Main meat", 198 | "Vitamised", 199 | "Vegetables ", 200 | "Soup", 201 | ]; 202 | final _fixedRowCells = [ 203 | "Time Cooking or Reheating started", 204 | "Reheated temp.(° C)", 205 | "Reheating completed", 206 | "Reheating", 207 | "Vitamised (° C)", 208 | "Time plating begins", 209 | "Temp @ start of plating (° C)", 210 | "Time at last plate", 211 | "Sign", 212 | "C/A- Register" 213 | ]; 214 | // CustomDataTable( 215 | // rowsCells: _rowsCells, 216 | // fixedColCells: _fixedColCells, 217 | // fixedRowCells: _fixedRowCells, 218 | // fixedCornerCell: "Product", 219 | // cellBuilder: (data) { 220 | // return Text('$data', 221 | // style: AppStyle.mediumTextStyle(color: Colors.black)); 222 | // }) 223 | -------------------------------------------------------------------------------- /dependency_overrides.dart: -------------------------------------------------------------------------------- 1 | name: yoshan 2 | description: A new Flutter project. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # In Android, build-name is used as versionName while build-number used as versionCode. 10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 12 | # Read more about iOS versioning at 13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 14 | version: 1.0.0+1 15 | 16 | environment: 17 | sdk: ">=2.1.0 <3.0.0" 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | camera: 23 | path_provider: 24 | path: 25 | month_picker_dialog: 26 | flutter_calendar_carousel: 27 | intl: ^0.15.0 28 | 29 | # The following adds the Cupertino Icons font to your application. 30 | # Use with the CupertinoIcons class for iOS style icons. 31 | cupertino_icons: ^0.1.2 32 | 33 | image_picker: ^0.6.1 34 | url_launcher: ^5.1.1 35 | fluttertoast: 36 | 37 | http: ^0.12.0+2 38 | dependency_overrides: 39 | intl: ^0.16.0 40 | dev_dependencies: 41 | flutter_test: 42 | sdk: flutter 43 | 44 | # For information on the generic Dart part of this file, see the 45 | # following page: https://dart.dev/tools/pub/pubspec 46 | 47 | # The following section is specific to Flutter. 48 | flutter: 49 | # The following line ensures that the Material Icons font is 50 | # included with your application, so that you can use the icons in 51 | # the material Icons class. 52 | uses-material-design: true 53 | 54 | # To add assets to your application, add an assets section, like this: 55 | assets: 56 | - images/ 57 | 58 | # An image asset can refer to one or more resolution-specific "variants", see 59 | # https://flutter.dev/assets-and-images/#resolution-aware. 60 | 61 | # For details regarding adding assets from package dependencies, see 62 | # https://flutter.dev/assets-and-images/#from-packages 63 | 64 | # To add custom fonts to your application, add a fonts section here, 65 | # in this "flutter" section. Each entry in this list should have a 66 | # "family" key with the font family name, and a "fonts" key with a 67 | # list giving the asset and other descriptors for the font. For 68 | # example: 69 | fonts: 70 | - family: Poppins 71 | fonts: 72 | - asset: font/Poppins/PoppinsBold.ttf 73 | - asset: font/Poppins/PoppinsRegular.ttf 74 | style: italic 75 | - family: CustomIcon 76 | fonts: 77 | - asset: font/CustomIcon.ttf 78 | # 79 | # For details regarding fonts from package dependencies, 80 | # see https://flutter.dev/custom-fonts/#from-packages 81 | -------------------------------------------------------------------------------- /developer1996.dart: -------------------------------------------------------------------------------- 1 | int a = 0 2 | bottomNavigationBar: BottomAppBar( 3 | clipBehavior: Clip.antiAlias, 4 | elevation: 0, 5 | color: Color.fromRGBO(197, 214, 226, 1), 6 | child: Column( 7 | mainAxisSize: MainAxisSize.min, 8 | mainAxisAlignment: MainAxisAlignment.end, 9 | children: [ 10 | Container( 11 | height: 5, 12 | width: double.infinity, 13 | color: Color.fromRGBO(96, 163, 209, 1.0), 14 | ), 15 | Padding( 16 | padding: const EdgeInsets.only(left: 8.0, right: 8.0), 17 | child: Container( 18 | height: 60, 19 | child: Align( 20 | alignment: FractionalOffset.center, 21 | child: new Row( 22 | //mainAxisSize: MainAxisSize.max, 23 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 24 | crossAxisAlignment: CrossAxisAlignment.center, 25 | children: [ 26 | IconButton( 27 | icon: ImageIcon(AssetImage("images/cal.png",) ,size: 30,), // icon: Icon( 28 | // CustomIcon.calendar_inv, 29 | // size: 35, 30 | // ), 31 | disabledColor: Color.fromRGBO(32, 127, 195, 1), 32 | color: Colors.white, 33 | onPressed: a == 0 34 | ? null 35 | : () => setState(() { 36 | a = 0; 37 | 38 | })), 39 | IconButton( 40 | icon: ImageIcon(AssetImage("images/edit.png",) ,size: 30,), 41 | disabledColor: Color.fromRGBO(32, 127, 195, 1), 42 | color: Colors.white, 43 | onPressed: a == 1 44 | ? null 45 | : () => setState(() => a = 1)), 46 | IconButton( 47 | icon: ImageIcon(AssetImage("images/notify.png",) ,size: 30,), 48 | disabledColor: Color.fromRGBO(32, 127, 195, 1), 49 | color: Colors.white, 50 | onPressed: a == 2 51 | ? null 52 | : () => setState(() { 53 | a = 2; 54 | 55 | })), 56 | IconButton( 57 | icon: ImageIcon(AssetImage("images/profile1.png",) ,size: 30,), 58 | disabledColor: Color.fromRGBO(32, 127, 195, 1), 59 | color: Colors.white, 60 | onPressed: a == 3 61 | ? null 62 | : () => setState(() { 63 | a = 3; 64 | 65 | })), 66 | ], 67 | ), 68 | ), 69 | ), 70 | ), 71 | ], 72 | )) 73 | -------------------------------------------------------------------------------- /drawer.dart: -------------------------------------------------------------------------------- 1 | //https://github.com/shiburagi/Drawer-Behavior-Flutter 2 | if (_scaffoldKey.currentState.isDrawerOpen) 3 | _scaffoldKey.currentState.openEndDrawer(); 4 | else { 5 | _scaffoldKey.currentState.openDrawer(); 6 | } 7 | 8 | 9 | final GlobalKey _scaffoldKey = new GlobalKey(); 10 | -------------------------------------------------------------------------------- /flaover.dart: -------------------------------------------------------------------------------- 1 | flutter build apk -t lib/main_dev.dart 2 | https://www.youtube.com/watch?v=DgGUtTUatDQ 3 | https://github.com/ResoCoder/environments_in_flutter_with_codemagic_tutorial 4 | -------------------------------------------------------------------------------- /flutter FAQ.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardik584/Flutter-lunchbox/12405c32c0e4e58cda64bd35c244b7540584e1ec/flutter FAQ.xlsx -------------------------------------------------------------------------------- /flutter2.0: -------------------------------------------------------------------------------- 1 | Flutter 2.0 2 | For null safely 3 | Change sdk in pubspec 4 | Environment: 5 | sdk: ‘>2.12.0 <3.0.0’ 6 | 7 | Without null safely (Normal project) 8 | Environment: 9 | sdk: ‘>2.7.0 <3.0.0’ 10 | 11 | 12 | 13 | 14 | Command for migrate our project to null safely 15 | dart migrate 16 | 17 | Command for Migrate, check and update latest version in pubspec 18 | dart pub outdated --mode=null-safety 19 | flutter pub upgrade --major-versions 20 | dart migrate --skip-import-check 21 | 22 | Command for update flutter inside your project .flutter 23 | sh flutterw upgrade 24 | 25 | 26 | 27 | 28 | 29 | String => Non nullable => You can’t pass null inside a non nullable variable , and if you still try to pass null value inside it then the dart compiler will show AOT compile time error warning. 30 | Ex: String name; 31 | 32 | String? => Nullable String => You can pass null or value inside it but you must have to apply condition before using nullable string 33 | Ex: String? name 34 | 35 | Late => define later => If you will declare variable in the class and that variable init later then you must have to use late keyword before variable name 36 | Ex: late String name; 37 | 38 | 39 | ! => When the variable type is nullable and if the value might come null in the variable and still you wanna accept it then you can use ! after variable name. 40 | Example: 41 | String? name; 42 | Text(name!); //When you will put ! after variable name then compiler will remove warning error 43 | 44 | There are many ways to handle nullable things instead of ! operator 45 | 1. Hard If Else condition 46 | Example : 47 | String? name; 48 | if(name != null) 49 | { 50 | Text(name); 51 | } 52 | 53 | 2. ?? operator 54 | Example : 55 | String? name; 56 | Text(name??’test’); 57 | 58 | 59 | 3. ! Operator 60 | Example : 61 | String? name; 62 | Text(name!); // It will ignore null check cause You are using ! operator 63 | 64 | 65 | 66 | 67 | 68 | 4. ?. Operator 69 | Example 70 | Class A{ 71 | String? a; 72 | String? b; 73 | A(this.a,this.b) 74 | } 75 | A a = A(null,”textB”) 76 | 77 | Text(a?.a??’-’); 78 | Text(a?.b??’-’); 79 | 80 | 81 | 82 | 83 | 84 | 85 | Full Code Example 86 | 87 | import 'dart:math'; 88 | void main() { 89 | Person a = Person(name: "hardik",facSport: "volly"); 90 | Person b = Person(name: "aes",facSport: "cricket"); 91 | Person c = Person(name: "hello",facSport: null,); 92 | Person d = Person(name: "aes",); 93 | 94 | func(String name){ 95 | print("Problem " + name); 96 | } 97 | 98 | String? currentName; 99 | if(currentName != null){ 100 | func(currentName); 101 | }else{ 102 | } 103 | 104 | func(currentName??'null hato'); 105 | func(currentName!); 106 | 107 | //define later 108 | late String currentUserName; 109 | if(Random().nextBool()){ 110 | currentUserName = "Hardik kUmbhani"; 111 | } 112 | 113 | print("random" + currentUserName); 114 | 115 | } 116 | 117 | class Person{ 118 | 119 | final String name; 120 | final String? facSport; 121 | Person({required this.name,this.facSport}); 122 | } 123 | 124 | -------------------------------------------------------------------------------- /flutter_appLifeCycle.dart: -------------------------------------------------------------------------------- 1 | 2 | class Tempo extends StatefulWidget { 3 | Tempo({Key key}) : super(key: key); 4 | 5 | _TempoState createState() => _TempoState(); 6 | 7 | } 8 | 9 | class _TempoState extends State with WidgetsBindingObserver{ 10 | String aes ='1'; 11 | @override 12 | void dispose() { 13 | super.dispose(); 14 | print('4 dispose'); 15 | WidgetsBinding.instance.removeObserver(this); 16 | } 17 | 18 | @override 19 | void deactivate() { 20 | super.deactivate(); 21 | print('*6 deactivate'); 22 | } 23 | 24 | @override 25 | void didChangeDependencies() { 26 | super.didChangeDependencies(); 27 | print('*7 didChangeDependencies'); 28 | } 29 | @override 30 | void didChangeAppLifecycleState(AppLifecycleState state) { 31 | super.didChangeAppLifecycleState(state); if (state == AppLifecycleState.paused) { 32 | print('outside *11'); 33 | } 34 | if (state == AppLifecycleState.resumed) { 35 | print('inside *12'); 36 | } 37 | if (state == AppLifecycleState.inactive) { 38 | print('inactive *13'); 39 | } 40 | if (state == AppLifecycleState.suspending) { 41 | print('suspending *14'); 42 | } 43 | } 44 | 45 | @override 46 | void didUpdateWidget(Tempo oldWidget) { 47 | super.didUpdateWidget(oldWidget); 48 | print('*8 didUpdateWidget'); 49 | } 50 | 51 | @override 52 | void initState() { 53 | 54 | super.initState(); 55 | print('1 init'); 56 | WidgetsBinding.instance.addObserver(this); 57 | } 58 | @override 59 | Widget build(BuildContext context) { 60 | print('3 build'); 61 | return Scaffold( 62 | body: Column( 63 | children: [ 64 | Text(aes), 65 | RaisedButton( 66 | onPressed: (){ 67 | setState(() { 68 | print('*9 setstat'); 69 | aes = '0'; 70 | print('*10 setstat'); 71 | }); 72 | 73 | }, 74 | ), 75 | RaisedButton( 76 | child: Text('data'), 77 | onPressed: (){ 78 | Navigator.push(context, MaterialPageRoute(builder: (context)=>Third())); 79 | }, 80 | ), 81 | ], 82 | ) 83 | ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /flutter_launcher_icon.dart: -------------------------------------------------------------------------------- 1 | First of all you have to import flutter_launcher_icon library in your pubspec.yaml file 2 | and then 3 | dev_dependencies: 4 | flutter_test: 5 | sdk: flutter 6 | flutter_launcher_icons: ^0.7.4 7 | flutter_icons: 8 | image_path: "assets/images/icon.png" 9 | android: true 10 | ios: true 11 | 12 | and run this command 13 | flutter pub pub run flutter_launcher_icons:main 14 | -------------------------------------------------------------------------------- /game link.txt: -------------------------------------------------------------------------------- 1 | https://flutterawesome.com/tic-tac-toe-game-built-with-flutter/ 2 | https://flutterawesome.com/tag/games/ 3 | -------------------------------------------------------------------------------- /getlastdayofmonth.dart: -------------------------------------------------------------------------------- 1 | int getLastDayofMonth(DateTime now){ 2 | var beginningNextMonth = (now.month < 12) ? new DateTime(now.year, now.month + 1, 1) : new DateTime(now.year + 1, 1, 1); 3 | var lastDay = beginningNextMonth.subtract(new Duration(days: 1)).day; 4 | 5 | return lastDay; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /git branch: -------------------------------------------------------------------------------- 1 | git clone url 2 | cd project name 3 | git checkout yourbranch name 4 | 5 | -------------------------------------------------------------------------------- /google_map_marker.dart: -------------------------------------------------------------------------------- 1 | /// _getCustomMarkerBitmap 2 | /// This method is used to generate bitmap 3 | /// marker through custom painter 4 | Future _getCustomMarkerBitmap( 5 | { 6 | int fuelTypeProductId, 7 | int clusterCount = 0, 8 | bool isCluster = true}) async { 9 | 10 | /// Init the [Canvas] and [PictureRecorder] 11 | final PictureRecorder pictureRecorder = PictureRecorder(); 12 | final Canvas canvas = Canvas(pictureRecorder); 13 | final Paint paint1 = Paint()..style = PaintingStyle.stroke; 14 | 15 | /// condition for marker background image 16 | ui.Image markerImage; 17 | if (isCluster) { 18 | markerImage = clusterMarkerImage; 19 | } else { 20 | markerImage = normalMarkerImage; 21 | } 22 | 23 | /// For management of image marker with Rect 24 | final Size imageSize = 25 | Size(markerImage.width.toDouble(), markerImage.height.toDouble()); 26 | final Rect src = Offset.zero & imageSize; 27 | 28 | final Rect dst = Offset.zero & Size(imageSize.width, imageSize.height); 29 | canvas.drawImageRect( 30 | markerImage, src, dst, paint1..blendMode = BlendMode.colorBurn); 31 | 32 | /// condition for marker text 33 | String markerText = ''; 34 | if (isCluster) { 35 | markerText = clusterCount.toString(); 36 | } else { 37 | markerText = "146456.15546".toStringAsFixed(2); 38 | } 39 | 40 | /// For the render text string in marker 41 | final TextPainter painter = TextPainter(textDirection: TextDirection.ltr); 42 | 43 | painter.text = TextSpan( 44 | text: markerText, 45 | style: const TextStyle( 46 | fontSize: 34, 47 | color: Colors.black, 48 | fontWeight: FontWeight.w700, 49 | fontFamily: 'Lato'), 50 | ); 51 | painter.layout(); 52 | painter.paint( 53 | canvas, 54 | Offset(isCluster ? 120 : 130 - painter.width / 2.22, 67.10 - painter.height / 0.80)); 55 | 56 | /// For the convert canvas to [ui.Image] 57 | final ui.Image img = await pictureRecorder 58 | .endRecording() 59 | .toImage(imageSize.width.toInt(), imageSize.height.toInt()); 60 | final ByteData data = await img.toByteData(format: ImageByteFormat.png); 61 | 62 | /// return BitmapDescriptor of marker 63 | return BitmapDescriptor.fromBytes(data.buffer.asUint8List()); 64 | } 65 | -------------------------------------------------------------------------------- /gradlefileerror.gradle: -------------------------------------------------------------------------------- 1 | //When you got project error like gradle and something else like bla bla bla 2 | then change below code 3 | https://stackoverflow.com/questions/53157397/execution-failed-for-task-apppredebugbuild-in-flutter/57458839#57458839 4 | buildscript { 5 | ext.kotlin_version = '1.3.0' 6 | ############################### 7 | repositories { 8 | google() 9 | jcenter() 10 | maven { 11 | url 'https://dl.google.com/dl/android/maven2' 12 | } 13 | } 14 | 15 | dependencies { 16 | classpath 'com.android.tools.build:gradle:3.3.0' 17 | ################################################### 18 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 19 | classpath 'com.google.gms:google-services:4.3.2' 20 | } 21 | # when you found this kind of error then use paste below code inside buildscript 22 | #* What went wrong: 23 | #Execution failed for task ':app:preDebugBuild'. 24 | #> Android dependency 'androidx.exifinterface:exifinterface' has different version for the compile (1.0.0-rc01) and runtime (1.0.0) classpath. You should manually set the same version via DependencyResolution 25 | subprojects { 26 | project.configurations.all { 27 | resolutionStrategy.eachDependency { details -> 28 | if (details.requested.group == 'com.android.support' 29 | && !details.requested.name.contains('multidex') ) { 30 | details.useVersion "27.1.1" 31 | } 32 | 33 | if (details.requested.group == 'androidx.core' 34 | && !details.requested.name.contains('androidx') ) { 35 | details.useVersion "1.0.1" 36 | } 37 | } 38 | } 39 | } 40 | } 41 | 42 | allprojects { 43 | repositories { 44 | google() 45 | jcenter() 46 | } 47 | } 48 | 49 | rootProject.buildDir = '../build' 50 | subprojects { 51 | project.buildDir = "${rootProject.buildDir}/${project.name}" 52 | } 53 | subprojects { 54 | project.evaluationDependsOn(':app') 55 | } 56 | 57 | task clean(type: Delete) { 58 | delete rootProject.buildDir 59 | } 60 | 61 | -------------------------------------------------------------------------------- /graphql setup.dart: -------------------------------------------------------------------------------- 1 | import 'package:graphql/client.dart'; 2 | Future doGraphQLAPICall( 3 | {String httpURL, String token, String queryData, int length}) async { 4 | //////////////////////////////////////////////////////////////////////////////////////// 5 | Documentation 6 | // String graphUrl = "http://japaclub.iconflux.info/graphql"; 7 | 8 | // String readRepositories = r''' 9 | // query { 10 | // getProfile { 11 | // name, 12 | // email, 13 | // reminder_interval, 14 | // user_id, 15 | // city, 16 | // mobile 17 | // avatar 18 | 19 | // } 20 | // } 21 | // '''; 22 | // int nRepositories = 50; 23 | // String token = 24 | // "eyJhbGciOiJSUzI1NiIsImtpZCI6ImNlNWNlZDZlNDBkY2QxZWZmNDA3MDQ4ODY3YjFlZDFlNzA2Njg2YTAiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vamFwYWNsdWItZGV2IiwiYXVkIjoiamFwYWNsdWItZGV2IiwiYXV0aF90aW1lIjoxNTc3NDQ0Nzk0LCJ1c2VyX2lkIjoiRnB4VlNKcXdvUVU4ZXdkRjQzbVl3Nk5nazFSMiIsInN1YiI6IkZweFZTSnF3b1FVOGV3ZEY0M21ZdzZOZ2sxUjIiLCJpYXQiOjE1Nzc0NDQ3OTQsImV4cCI6MTU3NzQ0ODM5NCwicGhvbmVfbnVtYmVyIjoiKzkxODIzODI3ODE5NiIsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsicGhvbmUiOlsiKzkxODIzODI3ODE5NiJdfSwic2lnbl9pbl9wcm92aWRlciI6InBob25lIn19.A1hfnXwR8StrKeFA7viERbkAolQF45niVn_oY36h9DQh3-2SpPr_bk9N6DIZXEesdmRbZ04Z57Al_rv5JOFZvAGABbzjbZBH3YmpnO2DNEHaAmbw7uv4PbX1gdG46p84vwXm6OBDMEEm793w1BhaE5X3KFAM23x04RsMH4zGAxOugyCyzXy9a3tUSaDJSNR_KYFTYoNUSsGCwpG8xf08tr_TbRKzb6KdRIykzQDUwcmYyoTM4Ez524Pba0M3wjd6n-g6rUvjchltVsm9iBDfMf4bS99q10yazkFs3-z3mEvvbhc317TbV9Glb3xH9bUmN2_Wb-ILXp81eyV4nS4D7Q"; 25 | // doGraphQLAPICall( 26 | // httpURL: graphUrl, 27 | // length: 50, 28 | // queryData: readRepositories, 29 | // token: token) 30 | // .then((onValue) { 31 | // print(onValue); 32 | // }); 33 | //////////////////////////////////////////////////////////////////////////////////////////////////////// 34 | final HttpLink _httpLink = HttpLink( 35 | uri: httpURL, 36 | ); 37 | final AuthLink _authLink = AuthLink( 38 | getToken: () async => 'Bearer $token', 39 | ); 40 | final Link _link = _authLink.concat(_httpLink); 41 | final GraphQLClient _client = GraphQLClient( 42 | cache: InMemoryCache(), 43 | link: _link, 44 | ); 45 | final String readRepositories = queryData; 46 | final int nRepositories = length; 47 | final QueryOptions options = QueryOptions( 48 | document: readRepositories, 49 | variables: { 50 | 'nRepositories': nRepositories, 51 | }, 52 | ); 53 | final QueryResult result = await _client.query(options); 54 | 55 | if (result.hasErrors) { 56 | print(result.errors); 57 | return result.errors; 58 | } else { 59 | return result.data; 60 | } 61 | } 62 | Future doGraphQLMutationAPICall( 63 | {String httpURL, String token, String queryData, int length}) async { 64 | SharedPreferences pre = await SharedPreferences.getInstance(); 65 | 66 | DateTime tokenCheck = DateTime.parse(pre.getString(expiredTokenTime)); 67 | if (tokenCheck.isBefore(DateTime.now())) { 68 | FirebaseUser a = await FirebaseAuth.instance.currentUser(); 69 | var temp = await a.getIdToken(refresh: true); 70 | 71 | print(temp.token); 72 | print(temp.expirationTime); 73 | 74 | pre.setString(expiredTokenTime, temp.token); 75 | pre.setString("token", temp.token); 76 | } 77 | final HttpLink _httpLink = HttpLink( 78 | uri: httpURL, 79 | ); 80 | 81 | final AuthLink _authLink = AuthLink( 82 | getToken: () async => 'Bearer ${pre.getString("token")}', 83 | ); 84 | final Link _link = _authLink.concat(_httpLink); 85 | final GraphQLClient _client = GraphQLClient( 86 | cache: InMemoryCache(), 87 | link: _link, 88 | ); 89 | final String readRepositories = queryData; 90 | final int nRepositories = length; 91 | 92 | final MutationOptions options = MutationOptions( 93 | document: readRepositories, 94 | variables: { 95 | 'starrableId': nRepositories, 96 | }, 97 | ); 98 | bool network = await checkInternet(); 99 | if (network) { 100 | final QueryResult result = await _client.mutate(options); 101 | 102 | if (result.hasErrors) { 103 | print(result.errors); 104 | return {"status": "failed", "data": result.errors}; 105 | } else { 106 | print(result.data); 107 | return {"status": "success", "data": result.data}; 108 | } 109 | } else { 110 | return { 111 | "status": "failed", 112 | "data": [checkInternetMsg] 113 | }; 114 | } 115 | } 116 | 117 | -------------------------------------------------------------------------------- /handle_Red_error.dart: -------------------------------------------------------------------------------- 1 | 2 | //https://flutter.dev/docs/testing/errors 3 | 4 | import 'dart:io'; 5 | 6 | import 'package:flutter/foundation.dart'; 7 | import 'package:flutter/material.dart'; 8 | 9 | void main() { 10 | FlutterError.onError = (FlutterErrorDetails details) { 11 | FlutterError.dumpErrorToConsole(details); 12 | if (kReleaseMode) 13 | exit(1); 14 | }; 15 | runApp(MyApp()); 16 | } 17 | -------------------------------------------------------------------------------- /handshake expection.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'dart:convert'; 3 | 4 | 5 | import 'package:dio/dio.dart'; 6 | 7 | import 'package:flutter/material.dart'; 8 | import 'package:webview_flutter/webview_flutter.dart'; 9 | class MyHttpOverrides extends HttpOverrides{ 10 | @override 11 | HttpClient createHttpClient(SecurityContext? context){ 12 | return super.createHttpClient(context) 13 | ..badCertificateCallback = (X509Certificate cert, String host, int port)=> true; 14 | } 15 | } 16 | void main() { 17 | HttpOverrides.global = new MyHttpOverrides(); 18 | runApp(MyApp()); 19 | } 20 | 21 | class MyApp extends StatelessWidget { 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | return MaterialApp( 26 | title: 'Flutter Demo', 27 | theme: ThemeData( 28 | 29 | primarySwatch: Colors.blue, 30 | ), 31 | home: MyHomePage(title: 'Flutter Demo Home Page'), 32 | ); 33 | } 34 | } 35 | 36 | class MyHomePage extends StatefulWidget { 37 | MyHomePage({Key? key, required this.title}) : super(key: key); 38 | 39 | 40 | 41 | final String title; 42 | 43 | @override 44 | _MyHomePageState createState() => _MyHomePageState(); 45 | } 46 | 47 | class _MyHomePageState extends State { 48 | int _counter = 0; 49 | @override 50 | void initState() { 51 | // TODO: implement initState 52 | super.initState(); 53 | if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); 54 | } 55 | 56 | void _incrementCounter() { 57 | setState(() { 58 | 59 | _counter++; 60 | }); 61 | } 62 | 63 | @override 64 | Widget build(BuildContext context) { 65 | 66 | return Scaffold( 67 | appBar: AppBar( 68 | 69 | title: Text(widget.title), 70 | ), 71 | body: Center( 72 | 73 | child: Column( 74 | 75 | mainAxisAlignment: MainAxisAlignment.center, 76 | children: [ 77 | Text( 78 | 'You have pushed the button this many times:', 79 | ), 80 | Text( 81 | '$_counter', 82 | style: Theme.of(context).textTheme.headline4, 83 | ), 84 | 85 | ElevatedButton( 86 | onPressed: () { 87 | Navigator.push( 88 | context, 89 | MaterialPageRoute( 90 | builder: (context) => DioTest() 91 | ), 92 | ); 93 | }, 94 | child: Text("Dio 3")) 95 | ], 96 | ), 97 | ), 98 | 99 | ); 100 | } 101 | } 102 | 103 | 104 | class DioTest extends StatefulWidget { 105 | DioTest({Key? key}) : super(key: key); 106 | 107 | @override 108 | _DioTestState createState() => _DioTestState(); 109 | } 110 | 111 | class _DioTestState extends State { 112 | 113 | @override 114 | void initState() { 115 | // TODO: implement initState 116 | super.initState(); 117 | callDioApiCall(); 118 | } 119 | 120 | Future callDioApiCall()async { 121 | Dio dio = new Dio(); 122 | var onHttpClientCreate = 123 | (HttpClient client) { 124 | client.badCertificateCallback = 125 | (X509Certificate cert, String host, int port) => true; 126 | return client; 127 | }; 128 | var _client = new HttpClient(); 129 | _client.badCertificateCallback = 130 | (X509Certificate cert, String host, int port) => true; 131 | bool _certificateCheck(X509Certificate cert, String host, int port) => 132 | host == 'local.domain.ext'; // <- change 133 | 134 | HttpClient client = new HttpClient() 135 | ..badCertificateCallback = (_certificateCheck); 136 | // Response response =await Dio().get("https://node-api-jahaaj.herokuapp.com"); 137 | Map map = {"username":"sadads","password":"asdasda","device_id":"706cd586e3a3a1a5","os":"1","fcm_token":"","device_info":"Google","model_name":"sdk_gphone_x86_arm"}; 138 | Response response = await dio.post("https://api.lawcanvas.in:8046/api/account/sign-in",data: jsonEncode(map)); 139 | print(response.data); 140 | print(response.statusCode); 141 | } 142 | @override 143 | Widget build(BuildContext context) { 144 | return Scaffold( 145 | appBar: AppBar(), 146 | ); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /heroku deploy.js: -------------------------------------------------------------------------------- 1 | //Please create Procfile and put this 2 | //web: node app.js 3 | // and const port = process.env.PORT || 3000; 4 | -------------------------------------------------------------------------------- /http.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | void main() 3 | { 4 | var rawJson = '{"url":"http://blah.jpg","id":1}'; 5 | print(rawJson); 6 | print(rawJson.runtimeType); 7 | Map parsedJson = json.decode(rawJson); 8 | print(parsedJson.runtimeType); 9 | print(parsedJson['id']); 10 | var imageModel = ImageModel(id: parsedJson['id'],url: parsedJson['url']); 11 | print(imageModel.id); 12 | print(imageModel.url); 13 | } 14 | class ImageModel 15 | { 16 | int id; 17 | String url; 18 | ImageModel({this.id,this.url}); 19 | } 20 | *****************************************************************************************************************************\ 21 | Future Builder 22 | FutureBuilder( 23 | future: http.get("http://192.168.1.16:3000/userMsg"), 24 | builder: (context, snapshot) { 25 | if (snapshot.connectionState == ConnectionState.done) { 26 | if (snapshot.hasError) { 27 | return Container( 28 | child: Text("Something Went worng!"), 29 | ); 30 | } else { 31 | http.Response abcf = snapshot.data; 32 | var po = json.decode(abcf.body); 33 | return Container( 34 | child: Text(po["message"]), 35 | ); 36 | } 37 | } else { 38 | return LinearProgressIndicator(); 39 | } 40 | }, 41 | ), 42 | ********************************************************************** 43 | onPressed: () { 44 | if (Theme.of(context).platform == 45 | TargetPlatform.android) { 46 | Map user = { 47 | "username": userName.text, 48 | "password": userPassword.text, 49 | "app_type": 0 50 | }; 51 | http 52 | .post( 53 | "http://yoshan.co.nz/timesheet/api/login.php", 54 | body: json.encode(user), 55 | ) 56 | .then((onValue) { 57 | var a = json.decode(onValue.body); 58 | print(onValue.body); 59 | print(a["status"]); 60 | }); 61 | } else if (Theme.of(context).platform == 62 | TargetPlatform.iOS) {} 63 | 64 | // Navigator.pushReplacementNamed( 65 | // context, "/first"); 66 | }, 67 | -------------------------------------------------------------------------------- /https.dart: -------------------------------------------------------------------------------- 1 | class MyHttpOverrides extends HttpOverrides{ 2 | @override 3 | HttpClient createHttpClient(SecurityContext context){ 4 | return super.createHttpClient(context) 5 | ..badCertificateCallback = (X509Certificate cert, String host, int port)=> true; 6 | } 7 | } 8 | 9 | Future main() async { 10 | WidgetsFlutterBinding.ensureInitialized(); 11 | final savedThemeMode = await AdaptiveTheme.getThemeMode(); 12 | // ASHISH 13 | if (!kIsWeb) { 14 | await Firebase.initializeApp(); 15 | } 16 | HttpOverrides.global = new MyHttpOverrides(); 17 | } 18 | 19 | 20 | bool _certificateCheck(X509Certificate cert, String host, int port) => 21 | host == 'local.domain.ext'; // <- change 22 | 23 | HttpClient client = new HttpClient() 24 | ..badCertificateCallback = (_certificateCheck); 25 | 26 | _client.badCertificateCallback = 27 | (X509Certificate cert, String host, int port) => true; 28 | -------------------------------------------------------------------------------- /image_fadeout.dart: -------------------------------------------------------------------------------- 1 | Image.network( 2 | "https://image.shutterstock.com/image-photo/mount-kilimanjaro-kenya-amboseli-national-260nw-472419487.jpg", 3 | frameBuilder: (BuildContext context, Widget child, int frame, 4 | bool wasSynchronouslyLoaded) { 5 | if (wasSynchronouslyLoaded) { 6 | return child; 7 | } 8 | return AnimatedOpacity( 9 | child: child, 10 | opacity: frame == null ? 0 : 1, 11 | duration: const Duration(seconds: 2), 12 | curve: Curves.easeOut, 13 | ); 14 | }, 15 | // loadingBuilder: (BuildContext context, Widget child, 16 | // ImageChunkEvent loadingProgress) { 17 | // if (loadingProgress == null) return child; 18 | // return Center( 19 | // child: CircularProgressIndicator( 20 | // value: loadingProgress.expectedTotalBytes != null 21 | // ? loadingProgress.cumulativeBytesLoaded / 22 | // loadingProgress.expectedTotalBytes 23 | // : null, 24 | // ), 25 | // ); 26 | // }, 27 | ), 28 | //plese use any one builder of them 29 | -------------------------------------------------------------------------------- /install_CocoaPods_without_sudo.md: -------------------------------------------------------------------------------- 1 | 1. Install homebrew via this command 2 | ```mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew``` 3 | 2. After successful installation of brew 4 | `eval "$(homebrew/bin/brew shellenv)" 5 | brew update --force --quiet 6 | chmod -R go-w "$(brew --prefix)/share/zsh"` 7 | 3. Install CocoaPods via this command 8 | ```brew install cocoapods``` 9 | 10 | Reference
11 | 1.https://www.youtube.com/watch?v=Hg7ukb5oxSA // How to Install CocoaPods With Gem or With Homebrew
12 | 2.https://www.youtube.com/watch?v=RT8Rh8yJy-w //Install Homebrew Without Sudo (macOS)
13 | 3.https://docs.brew.sh/Installation#untar-anywhere-unsupported
14 | 3.https://guides.cocoapods.org/using/getting-started.html#installation
15 | -------------------------------------------------------------------------------- /ios_generate_ipa_file: -------------------------------------------------------------------------------- 1 | 1. Go to 2 | 3 | /Volumes/80/Work/botanical_garden_gandhinagar/build/ios/Release-iphoneos/Runner.app 4 | 5 | 6 | 2. Create new folder as payload at following path, 7 | 8 | /Volumes/80/Work/botanical_garden_gandhinagar/build/ios/Release-iphoneos/ 9 | 10 | 3. put runner file inside the payload folder. 11 | 12 | 4. the compress payload folder 13 | now rename zip file as payload.ipa instead of payload.zip. 14 | 15 | now .ipa file ready to use ... 16 | 17 | 18 | Woohooooooooooooooooooooooooooo !!!!!!!!!! 19 | -------------------------------------------------------------------------------- /library.dart: -------------------------------------------------------------------------------- 1 | dots_indicator for swiper 2 | For Create Flutter project with package name and app name 3 | flutter create --org com.yourdomain vayro 4 | 5 | /////Circle Range Slider 6 | https://pub.dev/packages/flutter_circular_slider 7 | sleek_circular_slider 8 | https://pub.dev/packages/sleek_circular_slider 9 | -------------------------------------------------------------------------------- /listview_horizontal.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class Vessel extends StatefulWidget { 4 | Vessel({Key key}) : super(key: key); 5 | 6 | _VesselState createState() => _VesselState(); 7 | } 8 | 9 | class _VesselState extends State { 10 | @override 11 | Widget build(BuildContext context) { 12 | return Scaffold( 13 | backgroundColor: Color.fromRGBO(250, 251, 246, 1.0), 14 | appBar: AppBar( 15 | backgroundColor: Colors.white, 16 | leading: Icon( 17 | Icons.menu, 18 | color: Colors.black, 19 | ), 20 | title: Text( 21 | "Clean Nature", 22 | style: TextStyle(fontFamily: "lora", color: Colors.black), 23 | ), 24 | centerTitle: true, 25 | actions: [ 26 | IconButton( 27 | icon: Icon(Icons.shopping_cart, color: Colors.black), 28 | onPressed: () {}, 29 | ) 30 | ], 31 | ), 32 | body: SingleChildScrollView( 33 | child: Column( 34 | mainAxisSize: MainAxisSize.min, 35 | children: [ 36 | Padding( 37 | padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20), 38 | child: Row( 39 | mainAxisAlignment: MainAxisAlignment.start, 40 | children: [ 41 | Column( 42 | crossAxisAlignment: CrossAxisAlignment.start, 43 | children: [ 44 | Text( 45 | 'Help Us', 46 | style: TextStyle(fontFamily: "lora", fontSize: 40), 47 | ), 48 | Text( 49 | 'save planet earth', 50 | style: TextStyle(fontFamily: "lora", fontSize: 25), 51 | ) 52 | ], 53 | ), 54 | // Image.asset("images/leaf.png",height: 100,width: 180,) 55 | ], 56 | ), 57 | ), 58 | Padding( 59 | padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), 60 | child: TextField( 61 | style: TextStyle(fontFamily: "lora", color: Colors.black), 62 | decoration: new InputDecoration( 63 | hintText: 'Username', 64 | hintStyle: TextStyle(fontFamily: "lora", color: Colors.grey), 65 | prefixIcon: Icon( 66 | Icons.search, 67 | color: Colors.grey, 68 | ), 69 | filled: true, 70 | border: OutlineInputBorder( 71 | borderRadius: BorderRadius.circular(30)), 72 | enabledBorder: OutlineInputBorder( 73 | borderRadius: BorderRadius.circular(30), 74 | borderSide: const BorderSide( 75 | color: Color.fromRGBO(241, 241, 239, 1.0), width: 0.0), 76 | ), 77 | focusedBorder: OutlineInputBorder( 78 | borderRadius: BorderRadius.circular(30), 79 | borderSide: const BorderSide( 80 | color: Color.fromRGBO(241, 241, 239, 1.0), width: 0.0), 81 | ), 82 | fillColor: Color.fromRGBO(241, 241, 239, 1.0), 83 | ), 84 | ), 85 | ), 86 | Text( 87 | 'Best sellers', 88 | style: TextStyle(fontFamily: "lora"), 89 | textAlign: TextAlign.right, 90 | ), 91 | SizedBox( 92 | height: 20, 93 | ), 94 | SizedBox( 95 | height: 300, 96 | child: Padding( 97 | padding: const EdgeInsets.all(8.0), 98 | child: ListView.separated( 99 | separatorBuilder: (c, i) { 100 | return SizedBox( 101 | width: 20, 102 | ); 103 | }, 104 | shrinkWrap: true, 105 | physics: ClampingScrollPhysics(), 106 | scrollDirection: Axis.horizontal, 107 | itemCount: 3, 108 | itemBuilder: (BuildContext context, int index) => Card( 109 | shape: OutlineInputBorder( 110 | borderRadius: BorderRadius.circular(20), 111 | borderSide: BorderSide(color: Colors.white)), 112 | child: Container( 113 | height: 50, 114 | width: 200, 115 | decoration: BoxDecoration( 116 | color: Colors.white, 117 | borderRadius: BorderRadius.circular(20), 118 | ), 119 | child: Column( 120 | crossAxisAlignment: CrossAxisAlignment.center, 121 | children: [ 122 | SizedBox( 123 | height: 20, 124 | ), 125 | Image.asset( 126 | "images/brush${index + 1}.png", 127 | height: 150, 128 | width: 120, 129 | ), 130 | Padding( 131 | padding: const EdgeInsets.symmetric(horizontal: 25), 132 | child: Text( 133 | 'Bamboo Toothbrush', 134 | style: 135 | TextStyle(fontFamily: "lora", fontSize: 25), 136 | softWrap: true, 137 | ), 138 | ), 139 | Text( 140 | '4,90 \$', 141 | style: TextStyle( 142 | fontFamily: "lora", 143 | color: Color.fromRGBO(144, 194, 169, 1.0), 144 | fontSize: 20), 145 | ) 146 | ], 147 | ), 148 | ), 149 | ), 150 | ), 151 | ), 152 | ), 153 | SizedBox( 154 | height: 20, 155 | ), 156 | Text( 157 | 'New Product', 158 | style: TextStyle(fontFamily: "lora"), 159 | textAlign: TextAlign.right, 160 | ), 161 | SizedBox( 162 | height: 20, 163 | ), 164 | SizedBox( 165 | height: 150, 166 | child: Padding( 167 | padding: const EdgeInsets.all(8.0), 168 | child: ListView.separated( 169 | separatorBuilder: (c, i) { 170 | return SizedBox( 171 | width: 20, 172 | ); 173 | }, 174 | shrinkWrap: true, 175 | physics: ClampingScrollPhysics(), 176 | scrollDirection: Axis.horizontal, 177 | itemCount: 3, 178 | itemBuilder: (BuildContext context, int index) => InkWell( 179 | onTap: () { 180 | Navigator.push(context, 181 | MaterialPageRoute(builder: (context) => Product(tag:index,image:"images/brush${index + 1}.png" ,))); 182 | }, 183 | child: Card( 184 | child: Container( 185 | width: 250, 186 | child: Row( 187 | children: [ 188 | Hero( 189 | tag: index, 190 | child: Container( 191 | height: 100, 192 | child: Image.asset( 193 | "images/brush${index + 1}.png", 194 | ), 195 | ), 196 | ), 197 | Expanded( 198 | child: Wrap( 199 | children: [ 200 | Text( 201 | "Hello Hollywood", 202 | style: TextStyle( 203 | fontFamily: "lora", fontSize: 25), 204 | ), 205 | Text( 206 | '4,90 \$', 207 | style: TextStyle( 208 | fontFamily: "lora", 209 | color: 210 | Color.fromRGBO(144, 194, 169, 1.0), 211 | fontSize: 20), 212 | ) 213 | ], 214 | ), 215 | ), 216 | ], 217 | ), 218 | ), 219 | ), 220 | ), 221 | ), 222 | ), 223 | ), 224 | ], 225 | ), 226 | ), 227 | ); 228 | } 229 | } 230 | 231 | class Product extends StatefulWidget { 232 | final int tag; 233 | final String image; 234 | Product({this.image,this.tag,Key key}) : super(key: key); 235 | 236 | _ProductState createState() => _ProductState(); 237 | } 238 | 239 | class _ProductState extends State { 240 | @override 241 | Widget build(BuildContext context) { 242 | return Scaffold( 243 | appBar: AppBar( 244 | backgroundColor: Colors.white, 245 | ), 246 | body: Column( 247 | 248 | //mainAxisAlignment: MainAxisAlignment.center, 249 | children: [ 250 | SizedBox(height: 30,), 251 | Padding( 252 | padding: const EdgeInsets.symmetric(horizontal: 130), 253 | child: Hero( 254 | 255 | tag: widget. tag, 256 | child: Image.asset(widget.image), 257 | ), 258 | ) 259 | ], 260 | ), 261 | ); 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /localNotification.dart: -------------------------------------------------------------------------------- 1 | // declare variable. 2 | 3 | FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin; 4 | 5 | 6 | @override 7 | void initState() { 8 | super.initState(); 9 | flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); 10 | var android = AndroidInitializationSettings('mipmap/ic_launcher'); 11 | var initializationSettingsIOS = IOSInitializationSettings(); 12 | var initSetting = InitializationSettings(android,initializationSettingsIOS); 13 | flutterLocalNotificationsPlugin.initialize(initSetting,onSelectNotification: onselctionNotification,); 14 | } 15 | 16 | // make a function. 17 | 18 | Future onselctionNotification(String payload){ 19 | showDialog(context: context,builder: (_) => AlertDialog( 20 | title: Text("payload"), 21 | )); 22 | } 23 | 24 | // create another function for button click event to get Notification 25 | 26 | showNotification()async{ 27 | var android = AndroidNotificationDetails('channelId', 'channelName', 'channelDescription'); 28 | var ios = IOSNotificationDetails(); 29 | var platform = NotificationDetails(android, ios); 30 | await flutterLocalNotificationsPlugin.show(0, 'title', 'body', platform); 31 | } 32 | 33 | // add dependencies to Android Manifest file. 34 | 35 | 36 | 37 | // for Vibrate. 38 | 39 | 40 | -------------------------------------------------------------------------------- /loginpage.dart: -------------------------------------------------------------------------------- 1 | import 'package:cocktail/themes/appcolor.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class LoginPage extends StatefulWidget { 5 | LoginPage({Key key}) : super(key: key); 6 | 7 | @override 8 | _LoginPageState createState() => _LoginPageState(); 9 | } 10 | 11 | class _LoginPageState extends State { 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | resizeToAvoidBottomInset: false, 16 | resizeToAvoidBottomPadding: false, 17 | body: Stack( 18 | //fit: StackFit.expand, 19 | children: [ 20 | Positioned( 21 | right: 0, 22 | child: Container( 23 | height: 300, 24 | width: 300, 25 | decoration: BoxDecoration( 26 | gradient: LinearGradient(colors: [ 27 | AppColor.colorPink, 28 | AppColor.colorPink.withOpacity(0.7) 29 | ]), 30 | //backgroundBlendMode: BlendMode.exclusion, 31 | boxShadow: [ 32 | BoxShadow( 33 | blurRadius: 2, 34 | color: AppColor.colorPink.withOpacity(0.3), 35 | spreadRadius: 2, 36 | offset: Offset(10, 20), 37 | ) 38 | ], 39 | 40 | borderRadius: BorderRadius.only( 41 | bottomLeft: Radius.circular(800), 42 | ), 43 | ), 44 | ), 45 | ), 46 | Positioned( 47 | left: 0, 48 | child: Container( 49 | height: 200, 50 | width: 200, 51 | decoration: BoxDecoration( 52 | gradient: LinearGradient( 53 | colors: [ 54 | AppColor.colorOrange.withOpacity(1.0), 55 | AppColor.colorOrange, 56 | ], 57 | ), 58 | boxShadow: [ 59 | BoxShadow( 60 | blurRadius: 2, 61 | color: AppColor.colorOrange.withOpacity(0.3), 62 | spreadRadius: 2, 63 | offset: Offset(-18, 20), 64 | ) 65 | ], 66 | borderRadius: BorderRadius.only( 67 | bottomRight: Radius.circular(800), 68 | ), 69 | ), 70 | ), 71 | ), 72 | Positioned( 73 | bottom: -50, 74 | right: 0, 75 | child: Container( 76 | height: 100, 77 | width: 100, 78 | decoration: BoxDecoration( 79 | boxShadow: [ 80 | BoxShadow( 81 | blurRadius: 2, 82 | color: AppColor.colorPink.withOpacity(0.2), 83 | spreadRadius: 2, 84 | offset: Offset(12, -20), 85 | ) 86 | ], 87 | color: AppColor.colorPinkLight, 88 | borderRadius: BorderRadius.only( 89 | topLeft: Radius.circular(1000), 90 | ), 91 | ), 92 | ), 93 | ), 94 | Positioned( 95 | bottom: -130, 96 | right: 50, 97 | child: Container( 98 | height: 160, 99 | width: 160, 100 | decoration: BoxDecoration( 101 | gradient: LinearGradient( 102 | colors: [ 103 | AppColor.colorOrangeLight, 104 | AppColor.colorOrangeLight.withOpacity(0.7) 105 | ], 106 | ), 107 | boxShadow: [ 108 | BoxShadow( 109 | blurRadius: 2, 110 | color: AppColor.colorOrange.withOpacity(0.2), 111 | spreadRadius: 2, 112 | offset: Offset(-14, -10), 113 | ) 114 | ], 115 | color: AppColor.colorOrangeLight, 116 | borderRadius: BorderRadius.all( 117 | Radius.circular(1000), 118 | ), 119 | ), 120 | ), 121 | ), 122 | Scaffold( 123 | backgroundColor: Colors.transparent, 124 | body: SingleChildScrollView( 125 | child: Container( 126 | height: MediaQuery.of(context).size.height, 127 | alignment: Alignment.center, 128 | padding: EdgeInsets.all(15), 129 | child: Column( 130 | mainAxisAlignment: MainAxisAlignment.center, 131 | crossAxisAlignment: CrossAxisAlignment.start, 132 | children: [ 133 | Center( 134 | child: SizedBox( 135 | height: 80, 136 | width: 80, 137 | child: Container( 138 | decoration: BoxDecoration( 139 | borderRadius: BorderRadius.circular(10), 140 | image: DecorationImage( 141 | fit: BoxFit.scaleDown, 142 | image: NetworkImage( 143 | "https://www.infilon.com/wp-content/uploads/2018/05/favicon.png", 144 | ), 145 | ), 146 | color: Colors.white, 147 | boxShadow: [ 148 | BoxShadow( 149 | blurRadius: 15, 150 | color: Colors.black.withOpacity(0.2), 151 | spreadRadius: 5, 152 | ) 153 | ], 154 | ), 155 | ), 156 | ), 157 | ), 158 | SizedBox( 159 | height: 30, 160 | ), 161 | Text( 162 | "USERNAME", 163 | style: TextStyle( 164 | color: Colors.grey, fontWeight: FontWeight.w500), 165 | ), 166 | TextField(), 167 | SizedBox( 168 | height: 20, 169 | ), 170 | Text( 171 | "PASSWORD", 172 | style: TextStyle( 173 | color: Colors.grey, fontWeight: FontWeight.w500), 174 | ), 175 | TextField( 176 | decoration: InputDecoration( 177 | suffixText: "Forgot Password", 178 | suffixStyle: TextStyle( 179 | color: AppColor.colorPink, 180 | fontWeight: FontWeight.w500) 181 | //suffixIcon: Text("Forgot Password") 182 | ), 183 | ), 184 | SizedBox( 185 | height: 20, 186 | ), 187 | Container( 188 | height: 60, 189 | width: MediaQuery.of(context).size.width, 190 | child: RaisedButton( 191 | shape: OutlineInputBorder( 192 | borderRadius: BorderRadius.circular(5), 193 | borderSide: BorderSide.none, 194 | ), 195 | elevation: 10, 196 | onPressed: () {}, 197 | color: AppColor.colorPink, 198 | child: Text( 199 | "Sign In", 200 | style: TextStyle(color: Colors.white, fontSize: 20), 201 | ), 202 | ), 203 | ), 204 | SizedBox( 205 | height: 20, 206 | ), 207 | Center( 208 | child: RichText( 209 | text: TextSpan(children: [ 210 | TextSpan( 211 | text: "New to friendly Desi?", 212 | style: 213 | TextStyle(color: Colors.grey, fontSize: 20)), 214 | TextSpan(text: " "), 215 | TextSpan( 216 | text: "Sign Up", 217 | style: TextStyle( 218 | color: AppColor.colorPink, fontSize: 20)), 219 | ]), 220 | ), 221 | ) 222 | ], 223 | ), 224 | ), 225 | ), 226 | ) 227 | ], 228 | ), 229 | ); 230 | } 231 | } 232 | 233 | class AppColor { 234 | static Color colorPink = Color.fromRGBO(238, 86, 125, 1.0); 235 | static Color colorOrange = Color.fromRGBO(254, 172, 125, 1.0); 236 | static Color colorPinkLight = Color.fromRGBO(254, 227, 236, 1.0); 237 | static Color colorOrangeLight = Color.fromRGBO(228, 209, 204, 1.0); 238 | } 239 | -------------------------------------------------------------------------------- /multipart http request.dart: -------------------------------------------------------------------------------- 1 | buttonOnclick: () async { 2 | if (_formKey.currentState.validate()) { 3 | _formKey.currentState.save(); 4 | SharedPreferences pre = 5 | await SharedPreferences.getInstance(); 6 | var token = pre.getString("token"); 7 | 8 | 9 | // http 10 | // .post( 11 | // "http://192.168.196.32:8090/auth/signup", 12 | // headers: { 13 | // "token": token, 14 | // "Content-Type": "multipart/form-data" 15 | // }, 16 | // body: { 17 | // "name": nameController.text, 18 | // "email": emailController.text, 19 | // "mobile": "8238278196", 20 | // "address": addressController.text, 21 | // "city": cityController.text, 22 | // "reminder_interval": intervalValue, 23 | // }, 24 | // ) 25 | // .then((a) { 26 | // print(a); 27 | // }); 28 | 29 | var request = http.MultipartRequest( 30 | "POST", 31 | Uri.parse( 32 | "http://192.168.196.32:8090/auth/signup", 33 | ), 34 | ); 35 | Map headers = { 36 | 'Content-Type': 'multipart/form-data', 37 | 'token': token 38 | }; 39 | request.headers['token'] = token; 40 | request.headers["Content-Type"]='multipart/form-data'; 41 | request.fields["name"] = "hardik"; 42 | 43 | request.fields["email"] = "h@gmail.com"; 44 | request.fields["mobile"] = "8238278196"; 45 | request.fields["address"] = "afa"; 46 | request.fields["city"] = "fsf"; 47 | // if (image == null) { 48 | // ///request.fields[params_attachment_file] = ""; 49 | // } else { 50 | // var streamPhoto = new http.ByteStream( 51 | // DelegatingStream.typed(image.openRead())); 52 | // var lengthPhoto = await image.length(); 53 | // var multipartFile = new http.MultipartFile( 54 | // 'attachment_file', streamPhoto, lengthPhoto, 55 | // filename: basename(image.path)); 56 | // //contentType: new MediaType('image', 'png')); 57 | // request.files.add(multipartFile); 58 | // } 59 | if (image != null) { 60 | print(image.path.split(".").last); 61 | request.files.add( 62 | http.MultipartFile.fromBytes( 63 | "avatar", 64 | image.readAsBytesSync(), 65 | filename: "test.${image.path.split(".").last}", 66 | contentType: MediaType( 67 | "image", "${image.path.split(".").last}"), 68 | ), 69 | ); 70 | } 71 | request.fields["reminder_interval"] = "1"; 72 | 73 | request.send().then((onValue) { 74 | print(onValue.statusCode); 75 | 76 | print(onValue.headers); 77 | print(onValue.contentLength); 78 | }); 79 | 80 | // print(token); 81 | // Response response; 82 | // Dio dio = new Dio(); 83 | // response = await dio.post( 84 | // "http://192.168.196.32:8090/auth/signup", 85 | // data: profile, 86 | // options: Options( 87 | // contentType: "multipart/form-data", 88 | // 89 | // headers: { 90 | // "token": token, 91 | // "Content-Type": "multipart/form-data" 92 | // })); 93 | 94 | // Navigator.pushReplacementNamed( 95 | // context, AppConstant.profileRoute); 96 | } 97 | }, 98 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 99 | 100 | 101 | Future callAPIMultipartForResolveQuery( 102 | APICall apiCall, 103 | String url, 104 | String deviceId, 105 | int empId, 106 | String queryId, 107 | String solution, 108 | File file) async { 109 | try { 110 | String connectionStatus = 'Unknown'; 111 | final Connectivity _connectivity = new Connectivity(); 112 | /*Check INTERNET connection*/ 113 | connectionStatus = (await _connectivity.checkConnectivity()).toString() 114 | 115 | Future callAPIMultipartForResolveQuery( 116 | APICall apiCall, 117 | String url, 118 | String deviceId, 119 | int empId, 120 | String queryId, 121 | String solution, 122 | File file) async { 123 | try { 124 | String connectionStatus = 'Unknown'; 125 | final Connectivity _connectivity = new Connectivity(); 126 | /*Check INTERNET connection*/ 127 | connectionStatus = (await _connectivity.checkConnectivity()).toString(); 128 | if (connectionStatus == "ConnectivityResult.mobile" || 129 | connectionStatus == "ConnectivityResult.wifi") { 130 | apiCall.onChangeProgress(true); 131 | SharedPreferences prefs = await SharedPreferences.getInstance(); 132 | var result; 133 | String auth = prefs.getString(authorization); 134 | 135 | print("URL : $url"); 136 | 137 | print("AUTH_KEY : $auth"); 138 | 139 | var uri = Uri.parse(url); 140 | 141 | var request = new http.MultipartRequest("POST", uri); 142 | 143 | if (auth != null) { 144 | request.headers['Authorization'] = auth; 145 | } 146 | 147 | request.fields[params_emp_id] = empId.toString(); 148 | request.fields[params_device_id] = deviceId; 149 | request.fields[params_query_id]=queryId; 150 | request.fields[params_solution]=solution; 151 | 152 | 153 | if (file == null) { 154 | request.fields[params_attachment_file] = ""; 155 | } else { 156 | var streamPhoto = new http.ByteStream( 157 | DelegatingStream.typed(file.openRead())); 158 | var lengthPhoto = await file.length(); 159 | var multipartFile = new http.MultipartFile( 160 | 'attachment_file', streamPhoto, lengthPhoto, 161 | filename: basename(file.path)); 162 | //contentType: new MediaType('image', 'png')); 163 | request.files.add(multipartFile); 164 | } 165 | final response = await request.send(); 166 | //print(response); 167 | response.stream.transform(utf8.decoder).listen((value) async { 168 | result = json.decode(value); 169 | 170 | int code = result['code']; 171 | String msg = result['msg']; 172 | print(result); 173 | if (code == 200) { 174 | apiCall.onChangeProgress(false); 175 | apiCall.onSuccess(result); 176 | } else { 177 | apiCall.onChangeProgress(false); 178 | // showToast(msg); 179 | if (code == 201) { 180 | apiCall.onError(msg); 181 | } else if (code == 202) { 182 | apiCall.onError(msg); 183 | } else if (code == 400) { 184 | apiCall.onError(msg); 185 | } else if (code == 401) { 186 | apiCall.onError(msg); 187 | } else if (code == 403) { 188 | apiCall.onError(msg); 189 | } else if (code == 404) { 190 | apiCall.onError(msg); 191 | } else if (code == 601) { 192 | List list = result['error_msg']; 193 | String message = list.join("|"); 194 | apiCall.onError(message); 195 | } else { 196 | apiCall.onError(msg); 197 | //code = 500 or other than above 198 | } 199 | } 200 | }); 201 | return true; 202 | } else { 203 | //showToast("No INTERNET connection."); 204 | return false; 205 | } 206 | } catch (e) { 207 | print(e.toString()); 208 | return false; 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /native android.java: -------------------------------------------------------------------------------- 1 | package com.example.platformchannel; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.ContextWrapper; 6 | import android.content.Intent; 7 | import android.content.IntentFilter; 8 | import android.os.BatteryManager; 9 | import android.os.Build.VERSION; 10 | import android.os.Build.VERSION_CODES; 11 | import android.os.Bundle; 12 | import androidx.annotation.NonNull; 13 | import io.flutter.embedding.android.FlutterActivity; 14 | import io.flutter.embedding.engine.FlutterEngine; 15 | import io.flutter.plugin.common.EventChannel; 16 | import io.flutter.plugin.common.EventChannel.EventSink; 17 | import io.flutter.plugin.common.EventChannel.StreamHandler; 18 | import io.flutter.plugin.common.MethodChannel; 19 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler; 20 | import io.flutter.plugin.common.MethodChannel.Result; 21 | import io.flutter.plugin.common.MethodCall; 22 | import io.flutter.plugins.GeneratedPluginRegistrant; 23 | 24 | public class MainActivity extends FlutterActivity { 25 | private static final String BATTERY_CHANNEL = "samples.flutter.io/battery"; 26 | private static final String CHARGING_CHANNEL = "samples.flutter.io/charging"; 27 | 28 | @Override 29 | public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { 30 | new EventChannel(flutterEngine.getDartExecutor(), CHARGING_CHANNEL).setStreamHandler( 31 | new StreamHandler() { 32 | private BroadcastReceiver chargingStateChangeReceiver; 33 | @Override 34 | public void onListen(Object arguments, EventSink events) { 35 | chargingStateChangeReceiver = createChargingStateChangeReceiver(events); 36 | registerReceiver( 37 | chargingStateChangeReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); 38 | } 39 | 40 | @Override 41 | public void onCancel(Object arguments) { 42 | unregisterReceiver(chargingStateChangeReceiver); 43 | chargingStateChangeReceiver = null; 44 | } 45 | } 46 | ); 47 | 48 | new MethodChannel(flutterEngine.getDartExecutor(), BATTERY_CHANNEL).setMethodCallHandler( 49 | new MethodCallHandler() { 50 | @Override 51 | public void onMethodCall(MethodCall call, Result result) { 52 | if (call.method.equals("getBatteryLevel")) { 53 | int batteryLevel = getBatteryLevel(); 54 | 55 | if (batteryLevel != -1) { 56 | result.success(batteryLevel); 57 | } else { 58 | result.error("UNAVAILABLE", "Battery level not available.", null); 59 | } 60 | } else { 61 | result.notImplemented(); 62 | } 63 | } 64 | } 65 | ); 66 | } 67 | 68 | private BroadcastReceiver createChargingStateChangeReceiver(final EventSink events) { 69 | return new BroadcastReceiver() { 70 | @Override 71 | public void onReceive(Context context, Intent intent) { 72 | int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1); 73 | 74 | if (status == BatteryManager.BATTERY_STATUS_UNKNOWN) { 75 | events.error("UNAVAILABLE", "Charging status unavailable", null); 76 | } else { 77 | boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || 78 | status == BatteryManager.BATTERY_STATUS_FULL; 79 | events.success(isCharging ? "charging" : "discharging"); 80 | } 81 | } 82 | }; 83 | } 84 | 85 | private int getBatteryLevel() { 86 | if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { 87 | BatteryManager batteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE); 88 | return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY); 89 | } else { 90 | Intent intent = new ContextWrapper(getApplicationContext()). 91 | registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); 92 | return (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100) / 93 | intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /nfc check native.kt: -------------------------------------------------------------------------------- 1 | package com.iconflux.utility 2 | 3 | import androidx.annotation.NonNull; 4 | import io.flutter.embedding.android.FlutterActivity 5 | import io.flutter.embedding.engine.FlutterEngine 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | import android.nfc.NfcAdapter 8 | import io.flutter.plugin.common.MethodChannel 9 | 10 | class MainActivity: FlutterActivity() { 11 | private val CHANNEL = "samples.flutter.dev/nfc" 12 | fun isNfcEnabled(): Boolean { 13 | val nfcAdapter = NfcAdapter.getDefaultAdapter(this) 14 | if (nfcAdapter != null) { 15 | return try { 16 | nfcAdapter.isEnabled 17 | } catch (exp: Exception) { 18 | // Double try this as there are times it will fail first time 19 | try { 20 | nfcAdapter.isEnabled 21 | } catch (exp: Exception) { 22 | false 23 | } 24 | } 25 | } 26 | return false 27 | } 28 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 29 | GeneratedPluginRegistrant.registerWith(flutterEngine) 30 | MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { 31 | call, result -> 32 | if (call.method == "isNfcEnabled") { 33 | val nfcStatus = isNfcEnabled() 34 | 35 | if (nfcStatus != null) { 36 | result.success(nfcStatus) 37 | } else { 38 | result.success(false) 39 | } 40 | } else { 41 | result.notImplemented() 42 | } 43 | } 44 | } 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /null aware.dart: -------------------------------------------------------------------------------- 1 | https://medium.com/@thinkdigitalsoftware/null-aware-operators-in-dart-53ffb8ae80bb 2 | This is an updated version of Seth Ladd’s blog post about Null-aware operators in Dart. Most of the content is unchanged with the exception of the examples provided at the end of the post, which help make the post easier to understand. 3 | Null-aware operators in dart allow you to make computations based on whether or not a value is null. It’s shorthand for longer expressions. 4 | 5 | ?? 6 | Use ?? when you want to evaluate and return an expression IFF another expression resolves to null. 7 | exp ?? otherExp 8 | is similar to 9 | ((x) => x == null ? otherExp : x)(exp) 10 | ??= 11 | Use ??= when you want to assign a value to an object IFF that object is null. Otherwise, return the object. 12 | obj ??= value 13 | is similar to 14 | ((x) => x == null ? obj = value : x)(obj) 15 | ?. 16 | Use ?. when you want to call a method/getter on an object IFF that object is not null (otherwise, return null). 17 | obj?.method() 18 | is similar to 19 | ((x) => x == null ? null : x.method())(obj) 20 | You can chain ?. calls, for example: 21 | obj?.child?.child?.getter 22 | If obj, or child1, or child2 are null, the entire expression returns null. Otherwise, getter is called and returned. 23 | Update [4/19/2019] — Dart 2.3 24 | ?… 25 | Dart 2.3 brings in a spread operator (…) and with it comes a new null aware operator, ?... ! 26 | Placing ... before an expression inside a collection literal unpacks the result of the expression and inserts its elements directly inside the new collection. 27 | So now, these two are equivalent. 28 | List numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 29 | and 30 | List lowerNumbers = [1, 2, 3, 4, 5]; 31 | List upperNumbers = [6, 7, 8, 9, 10]; 32 | List numbers = […lowerNumbers…upperNumbers]; 33 | To benefit from the new null aware operator, you can use it like this. 34 | List lowerNumbers = [1, 2, 3, 4, 5]; 35 | List upperNumbers = [6, 7, 8, 9, 10]; 36 | List numbers = […lowerNumbers?…upperNumbers]; 37 | which is the equivalent to 38 | List numbers = []; 39 | numbers.addAll(lowerNumbers); 40 | if(upperNumbers != null){ 41 | numbers.addAll(upperNumbers); 42 | } 43 | -------------------------------------------------------------------------------- /on navigate notification: -------------------------------------------------------------------------------- 1 | https://inneka.com/programming/android/how-to-open-particular-screen-on-clicking-on-push-notification-for-flutter/ 2 | -------------------------------------------------------------------------------- /play local audio.dart: -------------------------------------------------------------------------------- 1 | import 'package:audioplayers/audio_cache.dart'; 2 | import 'package:audioplayers/audioplayers.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | typedef void OnError(Exception exception); 6 | 7 | void main() { 8 | runApp(new MaterialApp(home: new ExampleApp())); 9 | } 10 | 11 | class ExampleApp extends StatefulWidget { 12 | @override 13 | _ExampleAppState createState() => new _ExampleAppState(); 14 | } 15 | 16 | class _ExampleAppState extends State { 17 | Duration _duration = new Duration(); 18 | Duration _position = new Duration(); 19 | AudioPlayer advancedPlayer; 20 | AudioCache audioCache; 21 | 22 | @override 23 | void initState(){ 24 | super.initState(); 25 | initPlayer(); 26 | } 27 | 28 | void initPlayer(){ 29 | advancedPlayer = new AudioPlayer(); 30 | audioCache = new AudioCache(fixedPlayer: advancedPlayer); 31 | 32 | advancedPlayer.durationHandler = (d) => setState(() { 33 | _duration = d; 34 | }); 35 | 36 | advancedPlayer.positionHandler = (p) => setState(() { 37 | _position = p; 38 | }); 39 | } 40 | 41 | String localFilePath; 42 | 43 | Widget _tab(List children) { 44 | return Center( 45 | child: Container( 46 | padding: EdgeInsets.all(16.0), 47 | child: Column( 48 | children: children 49 | .map((w) => Container(child: w, padding: EdgeInsets.all(6.0))) 50 | .toList(), 51 | ), 52 | ), 53 | ); 54 | } 55 | 56 | Widget _btn(String txt, VoidCallback onPressed) { 57 | return ButtonTheme( 58 | minWidth: 48.0, 59 | child: RaisedButton(child: Text(txt), onPressed: onPressed)); 60 | } 61 | 62 | Widget slider() { 63 | return Slider( 64 | value: _position.inSeconds.toDouble(), 65 | min: 0.0, 66 | max: _duration.inSeconds.toDouble(), 67 | onChanged: (double value) { 68 | setState(() { 69 | seekToSecond(value.toInt()); 70 | value = value; 71 | });}); 72 | } 73 | 74 | Widget localAsset() { 75 | return _tab([ 76 | Text('Play Local Asset \'audio.mp3\':'), 77 | _btn('Play', () => audioCache.play('audio.mp3')), 78 | _btn('Pause',() => advancedPlayer.pause()), 79 | _btn('Stop', () => advancedPlayer.stop()), 80 | slider() 81 | ]); 82 | } 83 | 84 | void seekToSecond(int second){ 85 | Duration newDuration = Duration(seconds: second); 86 | 87 | advancedPlayer.seek(newDuration); 88 | } 89 | 90 | @override 91 | Widget build(BuildContext context) { 92 | return DefaultTabController( 93 | length: 1, 94 | child: Scaffold( 95 | appBar: AppBar( 96 | bottom: TabBar( 97 | tabs: [ 98 | Tab(text: 'Local Asset'), 99 | ], 100 | ), 101 | title: Text('audioplayers Example'), 102 | ), 103 | body: TabBarView( 104 | children: [localAsset()], 105 | ), 106 | ), 107 | ); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /portraitUp.dart: -------------------------------------------------------------------------------- 1 | SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) 2 | .then((_) { 3 | runApp(new MyApp()); 4 | }); 5 | -------------------------------------------------------------------------------- /primarySwatch.dart: -------------------------------------------------------------------------------- 1 | 2 | MaterialColor colorCustom = MaterialColor(0xFF0e8664, color); 3 | Map color = { 4 | 50: Color.fromRGBO(14,134,100, .1), 5 | 100: Color.fromRGBO(14,134,100, .2), 6 | 200: Color.fromRGBO(14,134,100, .3), 7 | 300: Color.fromRGBO(14,134,100, .4), 8 | 400: Color.fromRGBO(14,134,100, .5), 9 | 500: Color.fromRGBO(14,134,100, .6), 10 | 600: Color.fromRGBO(14,134,100, .7), 11 | 700: Color.fromRGBO(14,134,100, .8), 12 | 800: Color.fromRGBO(14,134,100, .9), 13 | 900: Color.fromRGBO(14,134,100, 1), 14 | }; 15 | 16 | return MaterialApp( 17 | debugShowCheckedModeBanner: false, 18 | title: 'Flutter Demo', 19 | theme: ThemeData( 20 | appBarTheme: AppBarTheme(color: Colors.orangeAccent, elevation: 0,brightness: Brightness.light,), 21 | primarySwatch: colorCustom, 22 | ), 23 | initialRoute: '/', 24 | onGenerateRoute: RouteGenerator.generateRoute, 25 | ); 26 | 27 | //for using hax value in MaterialColor just like 28 | #0040ff => 0xFF0040ff 29 | -------------------------------------------------------------------------------- /printing & pdf.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'dart:typed_data'; 3 | import 'dart:ui'; 4 | 5 | import 'package:dio/dio.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter/rendering.dart'; 8 | import 'package:flutter/services.dart'; 9 | import 'package:image/image.dart'; 10 | import 'package:image_picker/image_picker.dart'; 11 | import 'package:path_provider/path_provider.dart'; 12 | import 'package:pdf/pdf.dart'; 13 | import 'package:pdf/widgets.dart' as pwidget; 14 | import 'package:printing/printing.dart'; 15 | import 'package:pdf/pdf.dart' as pdfw; 16 | 17 | void main() => runApp(MyApp()); 18 | 19 | class MyApp extends StatelessWidget { 20 | @override 21 | Widget build(BuildContext context) { 22 | return MaterialApp( 23 | title: 'Flutter Demo', 24 | theme: ThemeData( 25 | primarySwatch: Colors.blue, 26 | ), 27 | home: MyHomePage(title: 'Flutter Demo Home Page'), 28 | ); 29 | } 30 | } 31 | 32 | class MyHomePage extends StatefulWidget { 33 | MyHomePage({Key key, this.title}) : super(key: key); 34 | 35 | final String title; 36 | 37 | @override 38 | _MyHomePageState createState() => _MyHomePageState(); 39 | } 40 | 41 | class _MyHomePageState extends State { 42 | int _counter = 0; 43 | File imagePick; 44 | var scr = new GlobalKey(); 45 | Future takeScreenShot() async { 46 | RenderRepaintBoundary boundary = scr.currentContext.findRenderObject(); 47 | 48 | var image = await boundary.toImage(pixelRatio: 10.0); 49 | 50 | ByteData byteData = await image.toByteData(format: ImageByteFormat.png); 51 | Uint8List pngBytes = byteData.buffer.asUint8List(); 52 | return pngBytes; 53 | } 54 | 55 | void _showQRandPrint() async { 56 | Dio dio = Dio(); 57 | 58 | var dirToSave = await getApplicationDocumentsDirectory(); 59 | 60 | await dio 61 | .download( 62 | "https://inducesmile.com/wp-content/uploads/2019/09/survey.png", 63 | "${dirToSave.path}/myImage.jpg", 64 | onReceiveProgress: (rec, total) {}) 65 | .then((onValue) {}); 66 | // File netImg = File("${dirToSave.path}/myImage.jpg"); 67 | final netImg = 68 | decodeImage(File("${dirToSave.path}/myImage.jpg").readAsBytesSync()); 69 | File imagepick = 70 | File("/storage/emulated/0/BizBox/11_1000151_1528288212591.jpg"); 71 | final img = decodeImage( 72 | File('/storage/emulated/0/BizBox/11_1000151_1528288212591.jpg') 73 | .readAsBytesSync()); 74 | final RenderRepaintBoundary boundary = 75 | scr.currentContext.findRenderObject(); 76 | var im = await boundary.toImage(pixelRatio: 10.0); 77 | final ByteData bytes = await im.toByteData(format: ImageByteFormat.rawRgba); 78 | //////////////////////////////////////////////////////////////////////////// 79 | final pwidget.Document document = pwidget.Document(); 80 | 81 | final PdfImage image = PdfImage(document.document, 82 | image: bytes.buffer.asUint8List(), width: im.width, height: im.height); 83 | 84 | final PdfImage image1 = PdfImage(document.document, 85 | image: img.data.buffer.asUint8List(), 86 | width: img.width, 87 | height: img.height); 88 | final PdfImage image2 = PdfImage(document.document, 89 | image: netImg.data.buffer.asUint8List(), 90 | width: netImg.width, 91 | height: netImg.height); 92 | 93 | document.addPage(pwidget.Page( 94 | pageFormat: PdfPageFormat.a4, 95 | build: (pwidget.Context context) { 96 | return pwidget.Center( 97 | child: pwidget.Expanded( 98 | child: pwidget.Image(image), 99 | ), 100 | ); // Center 101 | })); // Page 102 | document.addPage(pwidget.Page( 103 | pageFormat: PdfPageFormat.a4, 104 | build: (pwidget.Context context) { 105 | return pwidget.Center( 106 | child: pwidget.Expanded( 107 | child: pwidget.Image(image1), 108 | ), 109 | ); // Center 110 | })); 111 | document.addPage(pwidget.Page( 112 | pageFormat: PdfPageFormat.a4, 113 | build: (pwidget.Context context) { 114 | return pwidget.Center( 115 | child: pwidget.Expanded( 116 | child: pwidget.Image(image2), 117 | ), 118 | ); // Center 119 | })); 120 | // return document.save(); 121 | ///////////////////////////////////////////////////////////// 122 | final bool result = 123 | await Printing.layoutPdf(onLayout: (PdfPageFormat format) { 124 | return document.save(); 125 | }); 126 | } 127 | 128 | void _incrementCounter() async { 129 | ImagePicker.pickImage( 130 | source: ImageSource.gallery, 131 | ).then((a) async { 132 | imagePick = a; 133 | print(imagePick.absolute.uri); 134 | setState(() {}); 135 | // RenderRepaintBoundary boundary = scr.currentContext.findRenderObject(); 136 | 137 | // var imagee = await boundary.toImage(pixelRatio: 10.0); 138 | 139 | // ByteData byteData = 140 | // await imagee.toByteData(format: ImageByteFormat.rawRgba); 141 | // final pdf = new PDFDocument(); 142 | // final page = new PDFPage(pdf, pageFormat: PDFPageFormat(75.0, 100.0)); 143 | // final g = page.getGraphics(); 144 | // // final font = new PDFFont(pdf); 145 | 146 | // PDFImage image = new PDFImage(pdf, 147 | // image: byteData.buffer.asUint8List(), height: 200, width: 100); 148 | 149 | // g.drawImage( 150 | // image, 100.0 * PDFPageFormat.MM, 0.0, 75.0 * PDFPageFormat.MM); 151 | 152 | // Printing.printPdf(document: pdf); 153 | // pwidget.Image a = pwidget.Image(PdfImage(pdfDocument)); 154 | // pwidget.Image image = new pwidget.Image(PdfAnnot.urlLink()); 155 | 156 | // var pdf = pwidget.Document(pageMode: PdfPageMode.fullscreen); 157 | // pdf.addPage(pwidget.Page(build: (pwidget.Context context) { 158 | // return pwidget.Center( 159 | // child: pwidget.Image(PdfImage.jpeg(PDFDocument())), 160 | // ); // Center 161 | // })); 162 | // final output = await getTemporaryDirectory(); 163 | // final file = File("${output.path}/example.pdf"); 164 | // await file.writeAsBytes(pdf.save()); 165 | // Future.delayed(Duration(seconds: 2)); 166 | // await Printing.sharePdf(bytes: pdf.save(), filename: 'my-document.pdf'); 167 | // await Printing.layoutPdf( 168 | // onLayout: (PdfPageFormat format) async => pdf.save()); 169 | }); 170 | 171 | // Printing.layoutPdf(onLayout: (a) async { 172 | // return await Printing.convertHtml( 173 | // html: 174 | // 'Italian Trulli W3Schools.com', 175 | // format: PdfPageFormat.a4, 176 | // baseUrl: 177 | // "https://developer.android.com/topic/libraries/architecture/images/final-architecture.png"); 178 | // }); 179 | setState(() { 180 | _counter++; 181 | }); 182 | } 183 | 184 | @override 185 | Widget build(BuildContext context) { 186 | return Scaffold( 187 | appBar: AppBar( 188 | title: Text(widget.title), 189 | ), 190 | body: RepaintBoundary( 191 | key: scr, 192 | child: Container( 193 | color: Colors.indigo.withOpacity(.2), 194 | child: Center( 195 | child: Column( 196 | mainAxisAlignment: MainAxisAlignment.center, 197 | children: [ 198 | ListView.builder( 199 | shrinkWrap: true, 200 | itemCount: 5, 201 | itemBuilder: (context, index) { 202 | return ListTile( 203 | title: Text("Hello $index"), 204 | ); 205 | }, 206 | ), 207 | Text( 208 | 'You have pushed the button this many times:', 209 | ), 210 | Text( 211 | '$_counter', 212 | style: Theme.of(context).textTheme.display1, 213 | ), 214 | ], 215 | ), 216 | ), 217 | ), 218 | ), 219 | floatingActionButton: FloatingActionButton( 220 | onPressed: _showQRandPrint, 221 | tooltip: 'Increment', 222 | child: Icon(Icons.add), 223 | ), 224 | ); 225 | } 226 | } 227 | -------------------------------------------------------------------------------- /proguard-rules.pro: -------------------------------------------------------------------------------- 1 | ***************************************************************** 2 | Make file of proguard-rules.pro inside android/app 3 | #Flutter Wrapper 4 | -keep class io.flutter.app.** { *; } 5 | -keep class io.flutter.plugin.** { *; } 6 | -keep class io.flutter.util.** { *; } 7 | -keep class io.flutter.view.** { *; } 8 | -keep class io.flutter.** { *; } 9 | -keep class io.flutter.plugins.** { *; } 10 | -keep class com.google.firebase.** { *; } 11 | -dontwarn io.flutter.embedding.** 12 | -keep class com.dexterous.** { *; } 13 | -keep class com.transistorsoft.** { *; } 14 | -keep class com.crashlytics.** { *; } 15 | -keep class xyz.luan.** { *; } 16 | -keep class wakelock.** { *; } 17 | -keep class dexiumtech.phonestatei.** { *; } 18 | -keep class com.baseflow.** { *; } 19 | -keep class com.crazecoder.** { *; } 20 | -keep class io.github.ponnamkarthik.** { *; } 21 | -keep class de.esys.** { *; } 22 | -dontwarn com.crashlytics.** 23 | -ignorewarnings 24 | ********************************************************** 25 | In build.gradle 26 | buildTypes { 27 | release { 28 | // TODO: Add your own signing config for the release build. 29 | // Signing with the debug keys for now, so `flutter run --release` works. 30 | 31 | signingConfig signingConfigs.release 32 | minifyEnabled true 33 | useProguard true 34 | shrinkResources true 35 | 36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /refreshfirebasetoken.dart: -------------------------------------------------------------------------------- 1 | SharedPreferences pre = await SharedPreferences.getInstance(); 2 | 3 | DateTime tokenCheck = DateTime.parse(pre.getString(expiredTokenTime)); 4 | if (tokenCheck.isBefore(DateTime.now())) { 5 | FirebaseUser a = await FirebaseAuth.instance.currentUser(); 6 | var temp = await a.getIdToken(refresh: true); 7 | 8 | print(temp.token); 9 | print(temp.expirationTime); 10 | 11 | pre.setString(expiredTokenTime, temp.token); 12 | pre.setString("token", temp.token); 13 | } 14 | -------------------------------------------------------------------------------- /regex.dart: -------------------------------------------------------------------------------- 1 | email = RegExp(r"^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}") 2 | https://regexr.com 3 | -------------------------------------------------------------------------------- /release.dart: -------------------------------------------------------------------------------- 1 | Step 1: 2 | 3 | keytool -genkey -v -keystore ~/gmpbkey.jks -keyalg RSA -keysize 2048 -validity 10000 -alias gmpb 4 | //Please set your .key file name instand of gmpbkey.jks and alias name instand of gmpb respectivily 5 | //morever you have to follow all kind o f instruction provide in command promte 6 | 7 | Step 2: 8 | Make a key.properties file inside android/ folder 9 | like below as per your keystore file 10 | 11 | storePassword=flutter 12 | keyPassword=flutter 13 | keyAlias=gmpb 14 | storeFile=/Volumes/80/Work/gmpb/gmpbkey.jks 15 | 16 | Step 3: 17 | 18 | Inside app/build.gradle 19 | paste below 20 | //apply plugin: 'com.android.application' 21 | //apply plugin: 'kotlin-android' 22 | //apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 23 | 24 | def keystorePropertiesFile = rootProject.file("key.properties") 25 | def keystoreProperties = new Properties() 26 | keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) 27 | 28 | Step 4 29 | Inside app/build.gradle 30 | paste below 31 | //defaultConfig{} 32 | signingConfigs{ 33 | release{ 34 | keyAlias keystoreProperties['keyAlias'] 35 | keyPassword keystoreProperties['keyPassword'] 36 | storeFile file(keystoreProperties['storeFile']) 37 | storePassword keystoreProperties['storePassword'] 38 | } 39 | } 40 | 41 | Step 5 42 | change debug replace with release 43 | change buildTypes { 44 | release { 45 | // TODO: Add your own signing config for the release build. 46 | // Signing with the debug keys for now, so `flutter run --release` works. 47 | signingConfig signingConfigs.release 48 | } 49 | 50 | Step 6 51 | Enjoy your app and put on playstore 52 | -------------------------------------------------------------------------------- /rotate.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; // import this 2 | 3 | Transform( 4 | alignment: Alignment.center, 5 | transform: Matrix4.rotationY(math.pi), 6 | child: Icon(Icons.rotate_left, size: 100,), 7 | ) 8 | //https://stackoverflow.com/questions/58047009/flutter-how-to-flip-an-icon-to-get-mirror-effect 9 | //https://i.stack.imgur.com/GM2a8.png 10 | //https://i.stack.imgur.com/JHk4Z.png 11 | -------------------------------------------------------------------------------- /roundedAppBar: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class RoundedAppBar extends StatelessWidget implements PreferredSizeWidget { 4 | @override 5 | Widget build(BuildContext context) { 6 | return new SizedBox.fromSize( 7 | size: preferredSize, 8 | child: new LayoutBuilder(builder: (context, constraint) { 9 | final width = constraint.maxWidth * 8; 10 | return new ClipRect( 11 | child: new OverflowBox( 12 | maxHeight: double.infinity, 13 | maxWidth: double.infinity, 14 | child: new SizedBox( 15 | width: width, 16 | height: width, 17 | child: new Padding( 18 | padding: new EdgeInsets.only( 19 | bottom: width / 2 - preferredSize.height / 2), 20 | child: new DecoratedBox( 21 | decoration: new BoxDecoration( 22 | color: Colors.orange, 23 | shape: BoxShape.circle, 24 | boxShadow: [ 25 | new BoxShadow(color: Colors.black54, blurRadius: 10.0) 26 | ], 27 | ), 28 | ), 29 | ), 30 | ), 31 | ), 32 | ); 33 | }), 34 | ); 35 | } 36 | 37 | @override 38 | Size get preferredSize => const Size.fromHeight(200.0); 39 | } 40 | -------------------------------------------------------------------------------- /screenshot.dart: -------------------------------------------------------------------------------- 1 | https://stackoverflow.com/questions/51117958/how-to-take-a-screenshot-of-the-current-widget-flutter 2 | 3 | import 'dart:ui'; 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter/rendering.dart'; 7 | import 'package:work_organizer/screen/drawer_screen.dart'; 8 | import 'package:work_organizer/util/app_style.dart'; 9 | 10 | class WorkHourScreen extends StatefulWidget { 11 | WorkHourScreen({Key key}) : super(key: key); 12 | 13 | @override 14 | _WorkHourScreenState createState() => _WorkHourScreenState(); 15 | } 16 | 17 | class _WorkHourScreenState extends State { 18 | var scr= new GlobalKey(); 19 | var pngBytes; 20 | takescrshot() async { 21 | RenderRepaintBoundary boundary = scr.currentContext.findRenderObject(); 22 | var image = await boundary.toImage(); 23 | var byteData = await image.toByteData(format: ImageByteFormat.png); 24 | pngBytes= byteData.buffer.asUint8List(); 25 | print(pngBytes); 26 | } 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | appBar: AppBar( 31 | title: Text( 32 | "Workhours List", 33 | style: AppStyle.largeTextStyle(), 34 | ), 35 | centerTitle: true, 36 | ), 37 | drawer: DrawerScreen(), 38 | body: Column( 39 | children: [ 40 | RepaintBoundary( 41 | key: scr, 42 | child: Card( 43 | // key: Key(index.toString()), 44 | child: Padding( 45 | padding: const EdgeInsets.all(8.0), 46 | child: Column( 47 | 48 | children: [ 49 | Row( 50 | children: [ 51 | Text("Workhour",style: AppStyle.mediumTextStyle(),), 52 | Text("1") 53 | ], 54 | ), 55 | 56 | ], 57 | ), 58 | ), 59 | ), 60 | ), 61 | Image.memory(pngBytes) , 62 | // ListView.builder( 63 | // shrinkWrap: true, 64 | // itemCount: 10, 65 | // itemBuilder: (context, index) { 66 | // return RepaintBoundary( 67 | // key: scr, 68 | // child: Card( 69 | // // key: Key(index.toString()), 70 | // child: Padding( 71 | // padding: const EdgeInsets.all(8.0), 72 | // child: Column( 73 | 74 | // children: [ 75 | // Row( 76 | // children: [ 77 | // Text("Workhour",style: AppStyle.mediumTextStyle(),), 78 | // Text("$index") 79 | // ], 80 | // ), 81 | 82 | // ], 83 | // ), 84 | // ), 85 | // ), 86 | // ); 87 | // }, 88 | // ), 89 | RaisedButton( 90 | onPressed: (){takescrshot();setState(() { 91 | 92 | });}, 93 | child: Text("Click ss"), 94 | ), 95 | ], 96 | ), 97 | ); 98 | } 99 | } 100 | 101 | 102 | takeScreenShot() async{ 103 | RenderRepaintBoundary boundary = previewContainer.currentContext.findRenderObject(); 104 | ui.Image image = await boundary.toImage(); 105 | final directory = (await getApplicationDocumentsDirectory()).path; 106 | ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png); 107 | Uint8List pngBytes = byteData.buffer.asUint8List(); 108 | print(pngBytes); 109 | File imgFile =new File('$directory/screenshot.png'); 110 | imgFile.writeAsBytes(pngBytes); 111 | } 112 | 113 | -------------------------------------------------------------------------------- /screenutil text.dar: -------------------------------------------------------------------------------- 1 | static var mediumFontSize = ScreenUtil.getInstance().setSp(30); 2 | static var largeFontSize = ScreenUtil.getInstance().setSp(34); 3 | static var xLargeFontSize = ScreenUtil.getInstance().setSp(40); 4 | 5 | Widget build(BuildContext context) { 6 | ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); 7 | } 8 | every screen we have to put inside build 9 | -------------------------------------------------------------------------------- /searchList.dart: -------------------------------------------------------------------------------- 1 | sublist = abcdf 2 | .where((place) => place.properties.place 3 | .toLowerCase() 4 | .contains(searchtext.text.toLowerCase())) 5 | .toList(); 6 | -------------------------------------------------------------------------------- /setState in alert dialog.dart: -------------------------------------------------------------------------------- 1 | void showDailyJapaDialog( 2 | {BuildContext context, 3 | String dialogTitle, 4 | Function onADD, 5 | Function onSUB, 6 | String dialogTitleImageIcon, 7 | String bodyFirstHeader, 8 | String dialyJapaCount}) { 9 | showDialog( 10 | context: context, 11 | builder: (context) { 12 | return AlertDialog( 13 | contentPadding: EdgeInsets.all(10), 14 | titlePadding: EdgeInsets.all(0), 15 | title: getDialogTitle( 16 | dialogTitleImageIcon: dialogTitleImageIcon, 17 | dialogTitle: dialogTitle, 18 | context: context), 19 | content: StatefulBuilder( 20 | 21 | builder: (context, StateSetter setState) { 22 | return Column( 23 | mainAxisSize: MainAxisSize.min, 24 | crossAxisAlignment: CrossAxisAlignment.start, 25 | children: [ 26 | Text( 27 | bodyFirstHeader, 28 | style: AppStyle.smallTextStyle( 29 | color: AppColor.fontColorDarkBlue, 30 | ), 31 | ), 32 | SizedBox( 33 | height: 10, 34 | ), 35 | Row( 36 | children: [ 37 | Expanded( 38 | flex: 8, 39 | child: TextField( 40 | controller: 41 | TextEditingController(text: dialyJapaCount), 42 | style: AppStyle.mediumTextStyle( 43 | color: AppColor.fontColorDarkBlue, 44 | weight: FontWeight.w400, 45 | ), 46 | keyboardType: TextInputType.number, 47 | decoration: InputDecoration( 48 | border: 49 | OutlineInputBorder(borderSide: BorderSide.none), 50 | fillColor: AppColor.alertDialogTextFieldColor, 51 | filled: true), 52 | ), 53 | ), 54 | Expanded( 55 | flex: 5, 56 | child: Padding( 57 | padding: const EdgeInsets.only(left: 2), 58 | child: Container( 59 | height: 60, 60 | decoration: BoxDecoration( 61 | color: AppColor.alertDialogTextFieldColor, 62 | borderRadius: BorderRadius.circular(5)), 63 | child: Row( 64 | mainAxisAlignment: MainAxisAlignment.spaceAround, 65 | children: [ 66 | InkWell( 67 | onTap: (){ 68 | dialyJapaCount = 69 | (int.parse(dialyJapaCount) + 1) 70 | .toString(); 71 | setState(() {}); 72 | }, 73 | child: Image.asset( 74 | AppImage.getImage( 75 | imagename: "Promises/ic_add.png"), 76 | height: 25, 77 | width: 25, 78 | )), 79 | GestureDetector( 80 | onTap: (){ 81 | dialyJapaCount = 82 | (int.parse(dialyJapaCount) - 1) 83 | .toString(); 84 | setState(() {}); 85 | }, 86 | child: Image.asset( 87 | AppImage.getImage( 88 | imagename: "Promises/ic_sub.png"), 89 | height: 25, 90 | width: 25, 91 | )), 92 | ], 93 | ), 94 | ), 95 | ), 96 | ) 97 | ], 98 | ), 99 | SizedBox( 100 | height: 20, 101 | ), 102 | Padding( 103 | padding: const EdgeInsets.symmetric(horizontal: 10), 104 | child: getButtonWidget( 105 | title: "Save", buttonOnclick: () {Navigator.pop(context);}, context: context), 106 | ) 107 | ], 108 | ); 109 | } 110 | ), 111 | 112 | ); 113 | }); 114 | } 115 | -------------------------------------------------------------------------------- /setstate.dart: -------------------------------------------------------------------------------- 1 | @override 2 | void setState(fn) { 3 | if(mounted){ 4 | super.setState(fn); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /speechRec.dart: -------------------------------------------------------------------------------- 1 | class Indicator extends StatelessWidget { 2 | final Color color; 3 | final String text; 4 | final bool isSquare; 5 | final double size; 6 | final Color textColor; 7 | 8 | const Indicator({ 9 | Key key, 10 | this.color, 11 | this.text, 12 | this.isSquare, 13 | this.size = 16, 14 | this.textColor = const Color(0xff505050), 15 | }) : super(key: key); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return Row( 20 | children: [ 21 | Container( 22 | width: size, 23 | height: size, 24 | decoration: BoxDecoration( 25 | shape: isSquare ? BoxShape.rectangle : BoxShape.circle, 26 | color: color, 27 | ), 28 | ), 29 | SizedBox( 30 | width: 4, 31 | ), 32 | Text( 33 | text, 34 | style: TextStyle( 35 | fontSize: 16, fontWeight: FontWeight.bold, color: textColor), 36 | ) 37 | ], 38 | ); 39 | } 40 | } 41 | 42 | const languages = const [ 43 | const Language('Francais', 'fr_FR'), 44 | const Language('English', 'en_US'), 45 | const Language('Pусский', 'ru_RU'), 46 | const Language('Italiano', 'it_IT'), 47 | const Language('Español', 'es_ES'), 48 | ]; 49 | 50 | class Language { 51 | final String name; 52 | final String code; 53 | 54 | const Language(this.name, this.code); 55 | } 56 | 57 | class MyApp1 extends StatefulWidget { 58 | @override 59 | _MyApp1State createState() => new _MyApp1State(); 60 | } 61 | 62 | class _MyApp1State extends State { 63 | SpeechRecognition _speech; 64 | 65 | bool _speechRecognitionAvailable = false; 66 | bool _isListening = false; 67 | 68 | String transcription = ''; 69 | 70 | //String _currentLocale = 'en_US'; 71 | Language selectedLang = languages.first; 72 | 73 | @override 74 | initState() { 75 | super.initState(); 76 | activateSpeechRecognizer(); 77 | } 78 | 79 | // Platform messages are asynchronous, so we initialize in an async method. 80 | void activateSpeechRecognizer() { 81 | print('_MyAppState.activateSpeechRecognizer... '); 82 | _speech = new SpeechRecognition(); 83 | _speech.setAvailabilityHandler(onSpeechAvailability); 84 | _speech.setCurrentLocaleHandler(onCurrentLocale); 85 | _speech.setRecognitionStartedHandler(onRecognitionStarted); 86 | _speech.setRecognitionResultHandler(onRecognitionResult); 87 | _speech.setRecognitionCompleteHandler(onRecognitionComplete); 88 | 89 | _speech 90 | .activate() 91 | .then((res) => setState(() => _speechRecognitionAvailable = res)); 92 | } 93 | 94 | @override 95 | Widget build(BuildContext context) { 96 | return new MaterialApp( 97 | home: new Scaffold( 98 | appBar: new AppBar( 99 | title: new Text('SpeechRecognition'), 100 | actions: [ 101 | new PopupMenuButton( 102 | onSelected: _selectLangHandler, 103 | itemBuilder: (BuildContext context) => _buildLanguagesWidgets, 104 | ) 105 | ], 106 | ), 107 | body: new Padding( 108 | padding: new EdgeInsets.all(8.0), 109 | child: new Center( 110 | child: new Column( 111 | mainAxisSize: MainAxisSize.min, 112 | crossAxisAlignment: CrossAxisAlignment.stretch, 113 | children: [ 114 | new Expanded( 115 | child: new Container( 116 | padding: const EdgeInsets.all(8.0), 117 | color: Colors.grey.shade200, 118 | child: new Text(transcription))), 119 | _buildButton( 120 | onPressed: _speechRecognitionAvailable && !_isListening 121 | ? () => start() 122 | : null, 123 | label: _isListening 124 | ? 'Listening...' 125 | : 'Listen (${selectedLang.code})', 126 | ), 127 | _buildButton( 128 | onPressed: _isListening ? () => cancel() : null, 129 | label: 'Cancel', 130 | ), 131 | _buildButton( 132 | onPressed: _isListening ? () => stop() : null, 133 | label: 'Stop', 134 | ), 135 | ], 136 | ), 137 | )), 138 | ), 139 | ); 140 | } 141 | 142 | List> get _buildLanguagesWidgets => languages 143 | .map((l) => new CheckedPopupMenuItem( 144 | value: l, 145 | checked: selectedLang == l, 146 | child: new Text(l.name), 147 | )) 148 | .toList(); 149 | 150 | void _selectLangHandler(Language lang) { 151 | setState(() => selectedLang = lang); 152 | } 153 | 154 | Widget _buildButton({String label, VoidCallback onPressed}) => new Padding( 155 | padding: new EdgeInsets.all(12.0), 156 | child: new RaisedButton( 157 | color: Colors.cyan.shade600, 158 | onPressed: onPressed, 159 | child: new Text( 160 | label, 161 | style: const TextStyle(color: Colors.white), 162 | ), 163 | )); 164 | 165 | void start() => _speech 166 | .listen(locale: selectedLang.code) 167 | .then((result) => print('_MyAppState.start => result $result')); 168 | 169 | void cancel() => 170 | _speech.cancel().then((result) => setState(() => _isListening = result)); 171 | 172 | void stop() => _speech.stop().then((result) { 173 | setState(() => _isListening = result); 174 | }); 175 | 176 | void onSpeechAvailability(bool result) => 177 | setState(() => _speechRecognitionAvailable = result); 178 | 179 | void onCurrentLocale(String locale) { 180 | print('_MyAppState.onCurrentLocale... $locale'); 181 | setState( 182 | () => selectedLang = languages.firstWhere((l) => l.code == locale)); 183 | } 184 | 185 | void onRecognitionStarted() => setState(() => _isListening = true); 186 | 187 | void onRecognitionResult(String text) => setState(() => transcription = text); 188 | 189 | void onRecognitionComplete() => setState(() => _isListening = false); 190 | 191 | void errorHandler() => activateSpeechRecognizer(); 192 | } 193 | -------------------------------------------------------------------------------- /text recognize.dart: -------------------------------------------------------------------------------- 1 | // add below code in pubspec.yaml file 2 | module: 3 | androidX: true 4 | firebase_ml_vision: ^0.9.3+3 5 | image_picker: ^0.6.2+1 6 | 7 | //If you got error in your project then read this link 8 | https://github.com/hardik584/Flutter-lunchbox/blob/master/gradlefileerror.gradle 9 | 10 | import 'dart:io'; 11 | 12 | import 'package:firebase_ml_vision/firebase_ml_vision.dart'; 13 | import 'package:flutter/material.dart'; 14 | import 'package:image_picker/image_picker.dart'; 15 | 16 | class TextReco extends StatefulWidget { 17 | TextReco({Key key}) : super(key: key); 18 | 19 | @override 20 | _TextRecoState createState() => _TextRecoState(); 21 | } 22 | 23 | class _TextRecoState extends State { 24 | File _image; 25 | 26 | String text; 27 | Future getImage() async { 28 | var image = await ImagePicker.pickImage(source: ImageSource.camera); 29 | 30 | setState(() { 31 | _image = image; 32 | }); 33 | readText().then((onValue) { 34 | showDialog( 35 | context: context, 36 | builder: (context) { 37 | return AlertDialog( 38 | content: Text(onValue), 39 | ); 40 | }); 41 | }); 42 | } 43 | 44 | Future readText() async { 45 | text = ""; 46 | 47 | FirebaseVisionImage ourimage = FirebaseVisionImage.fromFile(_image); 48 | TextRecognizer reconizetext = FirebaseVision.instance.textRecognizer(); 49 | VisionText readtext = await reconizetext.processImage(ourimage); 50 | 51 | for (TextBlock block in readtext.blocks) { 52 | for (TextLine line in block.lines) { 53 | for (TextElement word in line.elements) { 54 | // print(word.text); 55 | 56 | text += word.text + " "; 57 | print(text); 58 | } 59 | } 60 | } 61 | return text; 62 | } 63 | 64 | @override 65 | Widget build(BuildContext context) { 66 | return Scaffold( 67 | appBar: AppBar( 68 | title: Text("Text Reco"), 69 | ), 70 | body: Center( 71 | child: _image == null ? Text('No image selected.') : Image.file(_image), 72 | ), 73 | floatingActionButton: FloatingActionButton( 74 | onPressed: getImage, 75 | tooltip: 'Pick Image', 76 | child: Icon(Icons.add_a_photo), 77 | ), 78 | ); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /text with overflow.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:infilon_user/util/app_color.dart'; 3 | import 'package:infilon_user/util/app_style.dart'; 4 | 5 | class TicketDetailPage extends StatefulWidget { 6 | TicketDetailPage({Key key}) : super(key: key); 7 | 8 | _TicketDetailPageState createState() => _TicketDetailPageState(); 9 | } 10 | 11 | class _TicketDetailPageState extends State { 12 | @override 13 | Widget build(BuildContext context) { 14 | var width = MediaQuery.of(context).size.width; 15 | var height = MediaQuery.of(context).size.height; 16 | AppStyle appStyle = AppStyle(); 17 | return Scaffold( 18 | appBar: AppBar( 19 | centerTitle: true, 20 | title: Text('Ticket'), 21 | ), 22 | bottomNavigationBar: Container( 23 | child: ButtonBar( 24 | alignment: MainAxisAlignment.spaceBetween, 25 | mainAxisSize: MainAxisSize.max, 26 | buttonPadding: EdgeInsets.symmetric(horizontal: 20), 27 | children: [ 28 | Container( 29 | width: width / 2.5, 30 | height: height * 0.07, 31 | decoration: 32 | BoxDecoration(borderRadius: BorderRadius.circular(50)), 33 | child: RaisedButton.icon( 34 | icon: Icon( 35 | Icons.close, 36 | color: Colors.red, 37 | ), 38 | onPressed: () {}, 39 | label: Text( 40 | "Close", 41 | style: appStyle.largeTextStyle(color: Colors.red), 42 | ), 43 | color: AppColor.primarySwatch, 44 | ), 45 | ), 46 | Container( 47 | width: width / 2.5, 48 | height: height * 0.07, 49 | decoration: 50 | BoxDecoration(borderRadius: BorderRadius.circular(10)), 51 | child: RaisedButton.icon( 52 | icon: Icon(Icons.message, color: Colors.white), 53 | onPressed: () {}, 54 | label: Text( 55 | "Chat", 56 | style: appStyle.largeTextStyle(color: Colors.white), 57 | ), 58 | color: AppColor.primarySwatch, 59 | ), 60 | ), 61 | ], 62 | ), 63 | ), 64 | body: Padding( 65 | padding: const EdgeInsets.all(8.0), 66 | child: Container( 67 | decoration: BoxDecoration( 68 | borderRadius: BorderRadius.all(Radius.circular(5)), 69 | border: Border.all(color: Colors.grey)), 70 | padding: EdgeInsets.all(15), 71 | child: ListView( 72 | children: [ 73 | Row( 74 | children: [ 75 | SizedBox( 76 | width: 75, 77 | child: Text( 78 | 'Subject', 79 | style: appStyle.mediumTextStyle(), 80 | ), 81 | ), 82 | SizedBox( 83 | width: 5, 84 | ), 85 | Text(':'), 86 | SizedBox( 87 | width: 5, 88 | ), 89 | Flexible( 90 | 91 | flex: 2, 92 | child: Text( 93 | 'Update data on support screen', 94 | style: appStyle.mediumTextStyle( 95 | color: AppColor.primarySwatch), 96 | ), 97 | ), 98 | ], 99 | ), 100 | SizedBox( 101 | height: 20, 102 | ), 103 | Row( 104 | children: [ 105 | SizedBox( 106 | width: 75, 107 | child: Text( 108 | 'Project', 109 | style: appStyle.mediumTextStyle(), 110 | )), 111 | SizedBox( 112 | width: 5, 113 | ), 114 | Text(':'), 115 | SizedBox( 116 | width: 5, 117 | ), 118 | Flexible( 119 | child: Text( 120 | 'PD soni', 121 | style: appStyle.mediumTextStyle( 122 | color: AppColor.primarySwatch), 123 | )), 124 | ], 125 | ), 126 | SizedBox( 127 | height: 20, 128 | ), 129 | Row( 130 | children: [ 131 | SizedBox( 132 | width: 75, 133 | child: Text( 134 | 'Language', 135 | style: appStyle.mediumTextStyle(), 136 | )), 137 | SizedBox( 138 | width: 5, 139 | ), 140 | Text(':'), 141 | SizedBox( 142 | width: 5, 143 | ), 144 | Flexible( 145 | child: Text( 146 | 'Flutter', 147 | style: appStyle.mediumTextStyle( 148 | color: AppColor.primarySwatch), 149 | )), 150 | ], 151 | ), 152 | SizedBox( 153 | height: 20, 154 | ), 155 | Row( 156 | children: [ 157 | SizedBox( 158 | width: 75, 159 | child: Text( 160 | 'Support Type', 161 | style: appStyle.mediumTextStyle(), 162 | )), 163 | SizedBox( 164 | width: 5, 165 | ), 166 | Text(':'), 167 | SizedBox( 168 | width: 5, 169 | ), 170 | Flexible( 171 | child: Text( 172 | 'Maintenance', 173 | style: appStyle.mediumTextStyle( 174 | color: AppColor.primarySwatch), 175 | )), 176 | ], 177 | ), 178 | SizedBox( 179 | height: 20, 180 | ), 181 | Row( 182 | children: [ 183 | SizedBox( 184 | width: 75, 185 | child: Text( 186 | 'Estimated Time', 187 | style: appStyle.mediumTextStyle(), 188 | )), 189 | SizedBox( 190 | width: 5, 191 | ), 192 | Text(':'), 193 | SizedBox( 194 | width: 5, 195 | ), 196 | Flexible( 197 | child: Text( 198 | '3 days', 199 | style: appStyle.mediumTextStyle( 200 | color: AppColor.primarySwatch), 201 | )), 202 | ], 203 | ), 204 | ], 205 | )), 206 | ), 207 | ); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /timer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:html'; 3 | 4 | Timer _timer; 5 | Color a = RandomColor().randomColor(); 6 | Color b = RandomColor().randomColor(); 7 | Color c = RandomColor().randomColor(); 8 | Color d = RandomColor().randomColor(); 9 | @override 10 | void initState() { 11 | super.initState(); 12 | changeColor(); 13 | } 14 | 15 | Future changeColor() async { 16 | _timer = Timer.periodic(Duration(milliseconds: 1000), (f) { 17 | setState(() { 18 | a = RandomColor().randomColor(); 19 | b = RandomColor().randomColor(); 20 | c = RandomColor().randomColor(); 21 | d = RandomColor().randomColor(); 22 | }); 23 | }); 24 | } 25 | 26 | @override 27 | void dispose() { 28 | _timer.cancel(); 29 | super.dispose(); 30 | } 31 | void responceSuccess(String responce) 32 | { 33 | print("reequest was successfully"); 34 | print(responce); 35 | } 36 | 37 | 38 | void responceError(String error) 39 | { 40 | print("reequest was not successfully"); 41 | print(error); 42 | } 43 | void abc() 44 | { 45 | print("main function done"); 46 | } 47 | void main() async 48 | { 49 | await abc(); 50 | await HttpRequest.getString('https://rebounce.online/api/time').then(responceSuccess).catchError(responceError); 51 | String ui = '655'; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /vscode.extensions: -------------------------------------------------------------------------------- 1 | 1 Auto Close Tag 2 | 2 Auto Complete Tag 3 | 3 Auto rename Tag 4 | 4 Awesome Flutter Snippets * 5 | 5 Babel Javascript 6 | 6 bloc 7 | 7 bracket jumper 8 | 8 bracket Pair Colorizer * 9 | 9 bracket pair colorizer 2 * 10 | 10 bracket selection 11 | 11 change-case 12 | 12 code spell checker 13 | 13 code time 14 | 14 color highlight 15 | 15 dart * 16 | 16 dart-import * 17 | 17 error lens 18 | 18 eslint 19 | 19 flutter * 20 | 20 flutter files 21 | 21 flutter stateful widget ge * 22 | 22 flutter widget snippets * 23 | 24 flutter widget wrap * 24 | 25 flutter auto import * 25 | 26 flutter stylizer * 26 | 27 git blame 27 | 28 live share 28 | 29 markdownlint 29 | 30 material icon theme * 30 | 31 npm 31 | 32 npm intellisence 32 | 33 paste json as code 33 | 34 path intellisense 34 | 35 prettier javascipr 35 | 36 pubspec assist * 36 | 37 rest client * 37 | 38 Sqlite 38 | 39 stackoverflow instant search * 39 | 40 todo highlight 40 | 41 todo tree 41 | 42 vscode-faker * 42 | 43 | * = Please note that when your are attend temp vs code code coding then add this exec in vs code 44 | -------------------------------------------------------------------------------- /web_flutter.dart: -------------------------------------------------------------------------------- 1 | flutter channel master 2 | flutter upgrade 3 | flutter config --enable-web 4 | cd 5 | flutter create . 6 | flutter run -d chrome 7 | 8 | https://flutter.dev/docs/get-started/web 9 | https://flutter.dev/docs/get-started/web 10 | -------------------------------------------------------------------------------- /willpopscope.dart: -------------------------------------------------------------------------------- 1 | SystemChannels.platform.invokeMethod('SystemNavigator.pop'); 2 | 3 | WillPopScope( 4 | onWillPop: (){ 5 | SystemChannels.platform.invokeMethod('SystemNavigator.pop'); 6 | }, 7 | child: AlertDialog( 8 | title: Text("No internet connection!"), 9 | 10 | actions: [ 11 | 12 | OutlineButton( 13 | onPressed: () { 14 | SystemChannels.platform.invokeMethod('SystemNavigator.pop'); 15 | }, 16 | child: Text("Cancel",style: TextStyle(color: Colors.red),), 17 | ), 18 | OutlineButton( 19 | onPressed: () { 20 | Navigator.pop(context); 21 | getDataLoad(); 22 | }, 23 | child: Text("Retry"), 24 | ), 25 | ], 26 | content: Text("Please try again later"), 27 | ), 28 | ), 29 | -------------------------------------------------------------------------------- /wireless device connect: -------------------------------------------------------------------------------- 1 | Attach device with pc 2 | Go to D:\android\sdk\platform-tools>adb tcpip 5555 3 | Find ip in your mobile device 4 | Now Detach device from your pc 5 | D:\android\sdk\platform-tools>adb connect 192.168.193.13:5555 6 | o/p: connected to 192.168.193.13:5555 7 | -------------------------------------------------------------------------------- /youtube api integration: -------------------------------------------------------------------------------- 1 | https://www.googleapis.com/youtube/v3/search?channelId=UCHiuq2uuSBeoGRtj4QqDvMw&part=snippet&order=date&maxResults=50&key=AIzaSyAm295YqmeHsk1tC-RbVD28tV2h3O1fQEk 2 | https://github.com/cvaditya1/youtube_data_v3/tree/1779da4dd1fd4af038e067454b617de16c1c4b0f 3 | --------------------------------------------------------------------------------