flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.22k stars 27.1k forks source link

SingleChildScrollView Widget is working well on Chrome Device but not well on Android Device #115073

Closed ravimandal06 closed 1 year ago

ravimandal06 commented 1 year ago

flutter logs Showing Mi A3 logs: I/flutter (26287): The Dart VM service is listening on http://127.0.0.1:40541/xQfsYr9nmA0=/ I/flutter (26287): Beans & Legumes I/flutter (26287): Grains & Cereals I/flutter (26287): Beans & Legumes

flutter doctor -v :

[√] Flutter (Channel master, 3.1.0-0.0.pre.2270, on Microsoft Windows [Version 10.0.22000.1098], locale en-IN) • Flutter version 3.1.0-0.0.pre.2270 on channel master at C:\Users\91707\fvm\default • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5fcd9c255e (3 months ago), 2022-08-14 08:39:21 -0700 • Engine revision f49a617535 • Dart version 2.19.0 (build 2.19.0-96.0.dev) • DevTools version 2.16.0

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc2) • Android SDK at C:\Users\91707\AppData\Local\Android\Sdk • Platform android-33, build-tools 33.0.0-rc2 • ANDROID_HOME = C:\Users\91707\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.9.4) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools • Visual Studio Build Tools 2019 version 16.9.31205.134 • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] VS Code (version 1.73.0) • VS Code at C:\Users\91707\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.52.0

[√] Connected device (4 available) • Mi A3 (mobile) • b46ef3f4f0c4 • android-arm64 • Android 11 (API 30) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.1098] • Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.106 • Edge (web) • edge • web-javascript • Microsoft Edge 107.0.1418.35

[√] HTTP Host Availability • All required HTTP hosts are available

• No issues found!

exaby73 commented 1 year ago

Hello @ravimandal06. Thank you for filing this issue. Can you please provide the following information?

Please provide the information in the form of text. See how to make collapsible sections with Markdown here.

ravimandal06 commented 1 year ago

Hello @ravimandal06. Thank you for filing this issue. Can you please provide the following information?

Please provide the information in the form of text. See how to make collapsible sections with Markdown here.

main.dart file is here:

Code Sample ```dart import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'screen/grocery_builder_screen.dart'; // ignore_for_file: prefer_typing_uninitialized_variables import 'dart:convert'; import 'package:animated_toggle_switch/animated_toggle_switch.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; import '../../models/groceries/groceries_model.dart'; import '../../services/networkHandler/network_handler.dart'; import '../Diet/individual_grocery.dart'; import '../controller/groceries/groceries_controller.dart'; import '../models/groceries/groceryItems.dart'; import '../widget/snap_scroll.dart'; import 'package:http/http.dart' as http; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:scroll_snap_list/scroll_snap_list.dart'; import '../models/groceries/groceryItems.dart'; import 'package:percent_indicator/circular_percent_indicator.dart'; import '../models/groceries/product.dart'; import 'dart:convert'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return ScreenUtilInit( designSize: const Size(360, 800), minTextAdapt: true, splitScreenMode: true, builder: (context, child) { return GetMaterialApp( debugShowCheckedModeBanner: false, title: 'WholesomeEten', // You can use the library anywhere in the app even in theme theme: ThemeData( primarySwatch: Colors.orange, textTheme: Typography.englishLike2018.apply(fontSizeFactor: 1.sp), ), routes: GetRoutes.routes, initialRoute: GetRoutes.grocery, ); }, ); } } class GetRoutes { static String grocery = '/grocery'; static var routes = { grocery: (_) => const GroceryBuilder(), }; } // import 'package:animated_toggle_switch/animated_toggle_switch.dart'; class GroceryBuilder extends StatefulWidget { const GroceryBuilder({super.key}); @override State createState() => _GroceryBuilderState(); } class _GroceryBuilderState extends State { bool automate = false; String dropdownvalue = "1 Week"; List weeks = ["1 Week", "2 Weeks"]; List quantities = ["100", "250", "500", "750", "1"]; List measuringUnit = ["gm", "gm", "gm", "gm", "kg"]; List groceries = [ "Grains & Cereals", "Beans & Legumes", "Meat", "Eggs", "Milk & Dairy", "Leafy Greens", "Roots & Tubers", "Other Veg", "Fruits", "Nuts & Seeds", "Oils & Fats" ]; List> totalGroceries = [ grainsCereals, beansLegumes, meat, eggs, milkDairy, leafyGreens, rootsTubers, otherVeg, fruits, nutsSeeds, oilFats, ]; Map conversionMap = { "CEREALS AND MILLETS": "Grains & Cereals", "GRAIN LEGUMES": "Beans & Legumes", "MEAT": "Meat", "EGG AND EGG PRODUCTS": "Eggs", "MILK AND MILK PRODUCTS": "Milk & Dairy", "GREEN LEAFY VEGETABLES": "Leafy Greens", "ROOTS, TUBERS, AND BULBS": "Roots & Tubers", "OTHER VEGETABLES": "Other Veg", "FRUITS": "Fruits", "NUTS AND OIL SEEDS": "Nuts & Seeds", "FATS AND OILS": "Oils & Fats", }; Map categoryPercent = { "Grains & Cereals": 0.0, "Beans & Legumes": 0.0, "Meat": 0.0, "Eggs": 0.0, "Milk & Dairy": 0.0, "Leafy Greens": 0.0, "Roots & Tubers": 0.0, "Other Veg": 0.0, "Fruits": 0.0, "Nuts & Seeds": 0.0, "Oils & Fats": 0.0 }; int selectedGrocery = 0; int _Current = 0; String selectedQuantity = "-QTY-"; Map quantityMap = {}; Map countMap = {}; Map measuringUnitMap = {}; Map adddeToList = {}; SnackBar showAddedtoListSnackBar(String title) { return SnackBar( duration: const Duration(seconds: 2), backgroundColor: Colors.black.withOpacity(0.7), behavior: SnackBarBehavior.floating, margin: EdgeInsets.only(bottom: 240.h, left: 10.w, right: 10.w), content: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.check_rounded, size: 15.h, color: Colors.white, ), SizedBox(width: 9.w), Text( title, style: TextStyle( color: Colors.white, fontSize: 14.sp, fontWeight: FontWeight.w700, fontFamily: "Roboto", ), ), ], ), ); } double indic_height(int heig, int ind) { if (ind > heig) { double ans = (6 * (1 - ind * 0.1)).h; return ans; } else if (ind < heig) { double ans = (7.5 - 6 * (1 - ind * 0.1)).h; return ans; } return 6.h; } Color getColor(double percent) { if (percent <= 0.25) { return const Color(0xffFFD15C); } else if (percent <= 0.50) { return const Color(0xff24F1A7); } else if (percent <= 0.75) { return const Color(0xfffa9746); } else if (percent <= 1.0) { return const Color(0xffF88968); } else { return const Color(0xffFF5A35); } } double getPercent() { return 0.0; } List foundIngredients = []; void searchFilter(String value) { List results = []; if (value.isEmpty) { results = totalGroceries[selectedGrocery]; } else { results = totalGroceries[selectedGrocery] .where((ingredient) => ingredient.toLowerCase().contains(value.toLowerCase())) .toList(); } setState(() { foundIngredients = results; }); } IndividualGrocery individualGrocery = IndividualGrocery(Energy: [0.0, "", ""]); //percentage-UI var groceriesController = Get.put(GroceriesController()); void getPercentage() async { final groceryData = await groceriesController.sendGroceries(); final data = jsonDecode(groceryData); print(data); individualGrocery = IndividualGrocery.fromJson(data); print("Individual Grocery Data => ${individualGrocery.Energy}"); categoryPercent[conversionMap[individualGrocery.Energy[2]]!] = individualGrocery.Energy[0]; //groceriesController.getUserGroceries(); setState(() {}); } void deleteGrocery() async { print("Inside delete Grocery"); final groceryData = await groceriesController.deleteGrocery(); final data = jsonDecode(groceryData); print("Deleted data is $data"); individualGrocery = IndividualGrocery.fromJson(data); print("Individual Grocery Data => ${individualGrocery.Energy}"); categoryPercent[conversionMap[individualGrocery.Energy[2]]!] = individualGrocery.Energy[0]; setState(() {}); } bool selected = false; bool toggle = false; String val = ''; String val1 = ''; ShapeBorder? get a => null; ShapeBorder? get b => null; double get t => 0; // @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: Stack( children: [ Material( elevation: 1.0, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(10.r), bottomRight: Radius.circular(10.r), ), child: Container( margin: EdgeInsets.only(left: 18.w, top: 25.h), height: 65.h, width: double.infinity, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(10.r), bottomRight: Radius.circular(10.r), ), ), child: Container( margin: EdgeInsets.only(top: 20.h), child: Text( "Grocery Builder", style: TextStyle( color: Colors.black, fontSize: 22.sp, fontWeight: FontWeight.w400, fontFamily: "ProductSans Medium", ), ), ), ), ), Align( alignment: Alignment.topRight, child: Image.asset("assets/images/illus.png"), ), Container( margin: EdgeInsets.only(left: 18.w, top: 110.h), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "Pick for", style: TextStyle( fontFamily: "ProductSans Regular", fontSize: 16.sp, fontWeight: FontWeight.w400, color: Colors.black.withOpacity(0.5)), ), SizedBox( width: 15.h, ), DropdownButton( underline: const SizedBox(), icon: const Icon(Icons.keyboard_arrow_down_rounded), items: weeks.map((String items) { return DropdownMenuItem( value: items, child: Row( children: [ Text( items, style: TextStyle( fontFamily: "Roboto Regular", fontSize: 14.sp, fontWeight: FontWeight.w400, color: const Color(0xff0C6E54), ), ), if (items == "2 Weeks") ...[ SizedBox( width: 5.w, ), // Image.asset("assetsimages//premiumIcon.png") ] ], ), ); }).toList(), onChanged: (String? newValue) { setState(() { dropdownvalue = newValue!; }); }, value: dropdownvalue, ), ], ), Padding( padding: EdgeInsets.only(right: 16.w), child: Row( children: [ Switch( value: automate, activeColor: const Color(0xffffffff), activeTrackColor: const Color(0xfffa9746), onChanged: (value) { setState(() { automate = value; }); }, ), Text( "Automate", style: TextStyle( fontFamily: "Roboto Regular", fontSize: 14.sp, fontWeight: FontWeight.w400, color: Colors.black.withOpacity(0.5), ), ), // SizedBox(width: 5.w,), ], ), ) ], ), SizedBox( height: 23.h, ), ], ), ), Container( margin: EdgeInsets.only(top: 164.h), width: 360.w, height: 217.h, // color: Colors.white, decoration: const BoxDecoration( boxShadow: [ BoxShadow( color: Color.fromRGBO(255, 255, 255, 1), // color: Colors.amber, blurRadius: 1, offset: Offset(0, 2), spreadRadius: 1, ), ], border: Border( bottom: BorderSide( width: 0.2, ), top: BorderSide(width: 0.1))), child: Center( child: SnapScroll( index: _Current, onItemFocused: (index) { setState(() { activeColor = index; // onSwipe(index); selectedIndex: _Current; _Current = index; selectedGrocery = index; foundIngredients = totalGroceries[selectedGrocery]; print(groceries[selectedGrocery]); }); }, ), ), ), Container( margin: EdgeInsets.only(top: 401.h), child: Padding( padding: EdgeInsets.symmetric(horizontal: 23.w), child: Material( elevation: 6.0, borderRadius: BorderRadius.circular(10.r), child: Container( height: 40.h, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.r), ), child: Row( children: [ Padding( padding: EdgeInsets.only(left: 13.w), child: Icon( Icons.search, color: Colors.black, size: 20.h, ), ), Expanded( child: TextField( cursorColor: Colors.black, enableSuggestions: false, onChanged: (value) { print(value); searchFilter(value); }, keyboardType: TextInputType.text, decoration: InputDecoration( border: InputBorder.none, hintText: selectedGrocery != -1 ? "Search in ${groceries[selectedGrocery]}" : "Search", hintStyle: TextStyle( color: Colors.grey, fontSize: 14.sp, ), contentPadding: EdgeInsets.symmetric( vertical: 8.h, horizontal: 8.h, ), isDense: true, ), style: TextStyle( fontSize: 14.sp, color: Colors.black, ), ), ) ], ), ), ), ), ), SingleChildScrollView( child: Container( margin: EdgeInsets.only(top: 474.h), width: double.infinity, height: 380.h, color: Colors.amber[50], child: Column( children: [ ListView.builder( itemCount: foundIngredients.length, itemBuilder: (BuildContext context, index) { return Material( borderRadius: BorderRadius.circular(10), elevation: 5, child: Container( width: 360, height: 58, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ const Text( 'Wheat Flour', style: TextStyle( color: Colors.black, fontWeight: FontWeight.w400, fontSize: 16, ), ), const SizedBox( width: 17, ), if (selected == false) ...[ InkWell( onTap: () async { var quantity = await Qty( context, foundIngredients[0]); setState(() { selected = true; val = quantity["selectedValue"]; val1 = quantity['selectedUnit']; }); }, child: Container( width: 88, height: 30, decoration: BoxDecoration( borderRadius: const BorderRadius.all( Radius.circular(5), ), border: Border.all( width: 2, color: Colors.grey, )), child: Center( child: Row(children: const [ SizedBox( width: 5, ), Text('-QTY-', style: TextStyle( color: Colors.grey, fontSize: 12, fontWeight: FontWeight.w400, )), SizedBox( width: 15, ), Center( child: Icon( Icons .keyboard_arrow_down_rounded, ), ), ]), ), )) ], if (selected == true) ...[ InkWell( onTap: () async { var quantity = await Qty( context, foundIngredients[0]); setState(() { selected = true; val = quantity["selectedValue"]; val1 = quantity['selectedUnit']; }); }, child: Text("$val $val1", style: const TextStyle( color: Colors.blue, )), ), ], const SizedBox( width: 5, ), SizedBox( width: 98, height: 36, child: AnimatedToggleSwitch.dual( current: toggle, first: false, second: true, borderRadius: BorderRadius.circular(100), dif: 5, borderColor: Colors.transparent, borderWidth: 5.0, height: 50, boxShadow: const [ BoxShadow( color: Colors.black26, spreadRadius: 1, blurRadius: 2, offset: Offset(0, 1.5), ), ], onChanged: (b) => setState(() { toggle = b; if (toggle == false) { setState(() { selected = false; }); } }), colorBuilder: (b) => b ? Colors.red : Colors.orange, iconBuilder: (value) => value ? Container( height: 20, width: 20, decoration: const BoxDecoration( shape: BoxShape .circle), child: const Icon( Icons.remove, color: Colors.white, size: 20, ), ) : Container( height: 20, width: 20, decoration: const BoxDecoration( shape: BoxShape .circle), child: const Icon( Icons.add, color: Colors.white, size: 20, ), ), textBuilder: (value) => value ? const Center( child: Text( 'Delete', style: TextStyle( fontWeight: FontWeight.w400, fontSize: 9, color: Color.fromRGBO( 68, 68, 68, 1)), )) : const Center( child: Text('Add', style: TextStyle( fontWeight: FontWeight.w400, fontSize: 10, color: Color.fromRGBO( 68, 68, 68, 1))), )), ), ])), ); }) ], ), ), ) ], ), ), ); } Future Qty(BuildContext context, String groceryItem) { return showDialog( context: context, builder: (BuildContext context) { int count = 1; var selectedValue; var selectedUnit; return StatefulBuilder( builder: (context, setState) { return Dialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.r), ), insetPadding: EdgeInsets.zero, clipBehavior: Clip.antiAliasWithSaveLayer, backgroundColor: Colors.transparent, child: Container( padding: EdgeInsets.symmetric(horizontal: 5.w), height: 342.h, width: 338.w, child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ const CloseIconWidget(), Container( height: 308.h, width: 328.w, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.r), color: Colors.white, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only( top: 16.h, left: 14.w, right: 21.w), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( groceryItem, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ GestureDetector( onTap: () { setState(() { if (count > 0) { count--; } }); }, child: Icon( Icons.remove, color: const Color(0xfffa9746), size: 20.h, ), ), SizedBox( width: 10.w, ), Text("$count"), SizedBox( width: 10.w, ), GestureDetector( onTap: () { setState(() { count++; }); }, child: Icon( Icons.add, size: 20.h, color: const Color(0xfffa9746), ), ), ], ) ], ), ), const Divider( color: Colors.black, ), Padding( padding: EdgeInsets.only(left: 12.w), child: const Text( "Select the Quantity", ), ), SizedBox( height: 8.h, ), Padding( padding: EdgeInsets.symmetric(horizontal: 11.w), child: Container( width: 305.w, height: 171.h, padding: EdgeInsets.only(top: 10.h, left: 21.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.r), color: const Color(0xffCBCBCB).withOpacity(0.1), ), child: ListView.builder( itemCount: quantities.length, shrinkWrap: true, itemBuilder: (context, index) { return Padding( padding: EdgeInsets.symmetric(vertical: 6.h), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: 16.h, width: 16.w, child: Radio( activeColor: const Color(0xfffa9746), value: quantities[index], materialTapTargetSize: MaterialTapTargetSize .shrinkWrap, groupValue: selectedValue, onChanged: (value) { setState(() { selectedValue = value; selectedUnit = measuringUnit[index]; }); }, ), ), SizedBox(width: 11.w), Text( "${quantities[index]} ${measuringUnit[index]}", ), ], ), ); }), ), ), SizedBox(height: 17.h), Align( alignment: Alignment.bottomRight, child: Padding( padding: EdgeInsets.only(right: 12.w), child: DialogButton( onPressed: () { setState(() { String res = "$count x $selectedValue"; Navigator.pop(context, { "selectedValue": selectedValue, "count": count, "selectedUnit": selectedUnit, }); print("Selected unit=$selectedUnit"); // print(quantityMap); }); }, yes: false, name: "Done", color: const Color(0xfffa9746), width: 83.w, height: 29.h, ), ), ), ], ), ), ], ), ), ); }, ); }); } } class DialogButton extends StatelessWidget { const DialogButton( {Key? key, required this.onPressed, required this.yes, required this.name, required this.color, required this.width, required this.height}) : super(key: key); final Function onPressed; final String name; final bool yes; final Color color; final double width; final double height; @override Widget build(BuildContext context) { return SizedBox( width: width, height: height, child: RawMaterialButton( splashColor: Colors.transparent, elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.r), side: yes == true ? BorderSide( width: 1.w, color: color, ) : BorderSide.none, ), fillColor: yes == true ? Colors.white : color, onPressed: () => onPressed(), child: Text( name, style: TextStyle( color: yes == true ? color : Colors.white, fontSize: 16.sp, fontFamily: "ProductSans Regular", fontWeight: FontWeight.w700, ), ), ), ); } } class CloseIconWidget extends StatelessWidget { const CloseIconWidget({ Key? key, }) : super(key: key); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(bottom: 10.h), decoration: const BoxDecoration( color: Color(0xffF7F7F7), shape: BoxShape.circle, ), child: GestureDetector( onTap: () { Navigator.pop(context, "-QTY-"); }, child: Icon( Icons.close, size: 24.h, color: Colors.black, ), ), ); } } class SnapScroll extends StatefulWidget { SnapScroll({Key? key, required this.onItemFocused, required this.index}) : super(key: key); void Function(int) onItemFocused; final int index; @override _SnapScrollState createState() => _SnapScrollState(); } int? activeColor = 0; int? elevation = 0; class _SnapScrollState extends State { List productList = [ Product('assets/images/1.png', 'assets/images/v5.png', 'Nuts & Beans', 15), Product('assets/images/1.png', 'assets/images/v6.png', 'Meat', 15), Product('assets/images/1.png', 'assets/images/v2.png', 'Oils', 15), Product('assets/images/1.png', 'assets/images/v4.png', 'Meat', 15), Product('assets/images/1.png', 'assets/images/v7.png', 'Grains', 15), Product('assets/images/1.png', 'assets/images/v8.png', 'Legumes', 15), Product('assets/images/1.png', 'assets/images/v9.png', 'Dairy', 15), Product('assets/images/1.png', 'assets/images/v1.png', 'Veggies', 15), Product('assets/images/1.png', 'assets/images/v3.png', 'Fruits', 15), ]; List grainsCereals = [ "Rajgira", "Pearl millet", "Barley", "Besan", "Jowar", "Sookha Makka", "Makka", "Sweet corn", "Pasta", "Wheat pasta", "Quinoa", "Ragi", "Poha", "Vermicelli", "Bhel", "Brown rice", "Parboiled rice", "Rice", "Little millet", "Kodo millet", "Refined wheat flour", "Wheat flour", "Wheat", "Bulgur", "Wheat rava", "Wheat vermicelli", "Roasted vermicelli", "Idli Rava", "Rolled oats", "Rice flour", "Idli Rice" ]; List beansLegumes = [ "Chana dal", "Chana", "Urad dal split", "Urad gota", "Brown Cowpea", "White Cowpea", "Black beans", "Brown beans", "White beans", "Moong dal", "Whole Moong", "Horse gram", "Toor dal", "Brown toor", "Yellow toor", "Moth bean", "Dry peas", "Black rajma", "Brown rajma", "Red Rajma", "Masoor dal", "Whole masoor", "Brown soy bean", "White soy bean" ]; List meat = [ "Chicken leg skinless", "Chicken thigh skinless", "Chicken breast skinless", "Chicken wing skinless", "Chicken liver", "Chicken gizzard", "Country Chicken leg", "Country Chicken thigh", "Country Chicken breast", "Country Chicken wing", "Duck meat", "Turkey leg", "Turkey thigh", "Turkey breast", "Goat shoulder", "Goat chops", "Goat legs", "Goat liver", "Sheep shoulder", "Sheep chops", "Sheep leg", "Sheep liver", "Beef shoulder", "Beef chops", "Beef liver", "Pork shoulder", "Pork chops", "Pork ham", "Rabbit, chops", "Rabbit, leg", "Anchovy", "Bombay duck", "Hilsa", "Milk fish", "White Pomfret", "Red snapper", "Salmon", "Sardine", "Shark", "Tilapia", "Tuna", "Vanjaram", "Sea crab", "Lobster", "Mud crab", "Oyster", "Tiger Prawns", "Clam", "Octopus", "Squid", "Cat fish", "Catla", "Freshwater Eel", "Pangas", "Rohu", "Crab", "Big prawns", "Small prawns", "Tiger prawns" ]; List eggs = [ "Egg", "Egg white", "Egg yolk", "Boiled egg", "Boiled egg white", "Boiled egg yolk", "Duck egg", "Quail egg", ]; List milkDairy = [ "Butter", "Cheese", "Buffalo milk", "Cow milk", "Paneer", "Khoa", "Yoghurt", ]; List leafyGreens = [ "Green Amaranth leaves", "Red Amaranth leaves", "Spiny Amaranth", "Malabar spinach", "Tulsi", "Beet greens", "Paan leaves", "Brussels sprouts", "Chinese cabbage", "Collard greens", "Green cabbage", "Violet cabbage", "Cauliflower leaves", "Colocasia leaves", "Drumstick leaves", "Methi leaves", "Gongura leaves", "Red gongura", "Lettuce", "Mustard leaves", "Parsley", "Ponnaganni", "Radish leaves", "Spinach", "Tamarind leaves", ]; List rootsTubers = [ "Beet root", "Carrot", "Colocasia", "Big potato", "Small Potato", "Radish", "Brown sweet potato", "Pink Sweet potato", "Water Chestnut", "Elephant Yam", "Yam", "Big Onion", "Small Onion" ]; List otherVeg = [ "Ash gourd", "Bitter gourd", "Bottle gourd", "Round Bottle gourd", "Brinjal", "Broad beans", "Capsicum", "Red capsicum", "Yellow Capsicum", "Cauliflower", "Celery stalk", "Chow chow", "Cluster beans", "Baby corn", "Cucumber", "Orange cucumber", "Drumstick", "Field beans", "French beans", "Raw Jack fruit", "Jack fruit seeds", "Knol Khol", "Tindora", "Ladies finger", "Raw Mango", "Spring onions", "Raw Papaya", "Fresh Peas", "Plantain flower", "Green Plantain", "Pumpkin", "Ridge gourd", "Snake gourd", "Hybrid tomato", "Local tomato", "Green Zucchini", "Yellow Zucchini", "Chillies", "Button mushrooms", "Shiitake mushrooms", "Dried oyster mushrooms", ]; List fruits = [ "Apple", "Green Apple", "Small Apple", "Kashmir Apple", "Dried Apricot", "Processed Apricot", "Avocado", "Banana", "Red Banana", "Kala Jamun", "Red Cherries", "Black Currant", "Custard apple", "Dried dates", "Processed dates", "Fig", "Gooseberry", "Seeded black grapes", "Seeded red grapes", "Seedless green grapes", "Seedless black grapes", "Guava", "Pink Guava", "Jack fruit", "Water apple", "Karonda", "Kiwi", "Lemon juice", "Mosambi", "Litchi", "Banganapalli Mango", "Neelam Mango", "Totapari Mango", "Mangosteen", "Manila Tamarind", "Musk melon", "Orange", "Palm fruit", "Papaya", "Peach", "Pear", "Pineapple", "Alubokhara", "Pomegranate", "Black Raisins", "Golden Raisins", "Rambutan", "Sapota", "Star fruit", "Strawberry", "Tamarind pulp", "Dark green Water melon", "Pale green Water melon", "Jujube", ]; List nutsSeeds = [ "Cashew nut", "Chia seeds", "Dry Coconut", "Fresh Coconut", "Haleem seeds", "Black Gingelly seeds", "White Gingelly seeds", "Ground nut", "Mustard seeds", "Flax seeds", "Niger seeds", "Pine nuts", "Pistachio nuts", "Safflower seeds", "Sunflower seeds", "Walnut", "Watermelon seeds", "Peanut Powder", ]; List oilFats = [ "Com oil", "Cotton seed oil", "Gingelly oil", "Groundnut oil", "Mustard oil", "Olive oil", "Palm oil", "Rice bran oil", "Safflower oil", "Safflower oil", "Soyabean oil", "Sunflower oil", "Ghee", "Vanaspati", "Coconut milk", ]; List herbs = [ "Coriander leaves", "Curry leaves", "Big Garlic", "Small Garlic", "Ginger", "Mango ginger", "Mint leaves", ]; List condiments = [ "Green Cardamom", "Black Cardamom", "Red Chillies", "Cloves", "Coriander seeds", "Cumin seeds", "Fenugreek seeds", "Mace", "Nutmeg", "Omum", "Pippali", "Black Pepper", "Poppy seeds", "Turmeric powder", "Table Salt", ]; List groceryIcons = [ "assets/images/grains.png", "assets/images/legumes.png", "assets/images/meat.png", "assets/images/eggs.png", "assets/images/milk.png", "assets/images/greens.png", "assets/images/grains.png", "assets/images/greens.png", "assets/images/fruits.png", "assets/images/nutsandbeans.png", "assets/images/oils.png" ]; List quantities = ["100", "250", "500", "750", "1"]; List measuringUnit = ["gm", "gm", "gm", "gm", "kg"]; List groceries = [ "Grains & Cereals", "Beans & Legumes", "Meat", "Eggs", "Milk & Dairy", "Leafy Greens", "Roots & Tubers", "Other Veg", "Fruits", "Nuts & Seeds", "Oils & Fats" ]; int selectedGrocery = 1; final int _Current = 0; String selectedQuantity = "-QTY-"; List> totalGroceries = [ grainsCereals, beansLegumes, meat, eggs, milkDairy, leafyGreens, rootsTubers, otherVeg, fruits, nutsSeeds, oilFats, ]; List listOpt = []; List foundIngredients = []; void onSwipe(int index) { List results = []; if (index != -1) { results = totalGroceries[selectedGrocery]; } else { results = totalGroceries[selectedGrocery].toList(); } setState(() { foundIngredients = results; }); } double indic_height(int heig, int ind) { if (ind > heig) { double ans = (6 * (1 - ind * 0.1)).h; return ans; } else if (ind < heig) { double ans = (7.5 - 6 * (1 - ind * 0.1)).h; return ans; } return 6.h; } void searchFilter(String value) { List results = []; if (value.isEmpty) { results = totalGroceries[selectedGrocery]; } else { results = totalGroceries[selectedGrocery] .where((ingredient) => ingredient.toLowerCase().contains(value.toLowerCase())) .toList(); } setState(() { foundIngredients = results; }); } Widget _buildItemList(BuildContext context, int index) { int selectedIndex; final double percentage; var color = const Color.fromRGBO(255, 209, 92, 0.1); Product product = productList[index]; if (index == productList.length) { return const Center( child: CircularProgressIndicator(), ); } items: List.generate(productList.length, (index) { foundIngredients; }); return SizedBox( width: 150, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(20)), child: SizedBox( // color: const Color.fromRGBO(255, 209, 92, 0.1), width: 112.w, height: 125.h, child: Container( // height: activeCorlor == index ? 125.h : 80.h, // width: activeColor == index ? 112.w : 75.w, decoration: BoxDecoration( boxShadow: activeColor == index ? [ const BoxShadow( color: Colors.transparent, blurRadius: 3, offset: Offset(0, 4), spreadRadius: 4, ), ] : [ const BoxShadow( blurRadius: 0, color: Colors.transparent, spreadRadius: 0, offset: Offset(0, 0), ), ], borderRadius: activeColor == index ? BorderRadius.circular(10.r) : BorderRadius.circular(0.r), color: activeColor == index ? const Color(0xffFFD15C).withOpacity(0.1) : Colors.transparent, border: Border.all( // width: activeColor == index ? 2.w : 0.w, color: activeColor == index ? Colors.black.withOpacity(0.1) : Colors.transparent, ), ), // color: const Color.fromRGBO(255, 209, 92, 0.1), child: Center( child: Container( margin: EdgeInsets.only(top: 1.h), child: CircularPercentIndicator( radius: 54.0.r, lineWidth: 4.0.w, backgroundColor: Colors.transparent, percent: 0.10, progressColor: Theme.of(context).colorScheme.secondary, circularStrokeCap: CircularStrokeCap.round, animation: true, center: CircleAvatar( radius: 45.0.r, backgroundColor: Colors.white, child: Column( children: [ SizedBox( height: 22.h, ), Image.asset( product.vectorPath, ), SizedBox( height: 10.h, ), Visibility( child: Text( // '${percentage.toStringAsFixed(0)} %', '10%', style: GoogleFonts.roboto( fontSize: 12.sp, fontWeight: FontWeight.w600, color: Colors.black, ), ), ), ], ), ), ), ), // child: CircleAvatar( // radius: 47.0.r, // backgroundColor: Colors.white, // child: Image.asset( // product.vectorPath, // ), // ), ), ), ), ), SizedBox( height: 10.h, ), SizedBox( // width: 37.w, // height: 17.h, child: Text( groceries[index], style: TextStyle( fontWeight: activeColor == index ? FontWeight.w700 : FontWeight.w400, fontSize: activeColor == index ? 12.sp : 9.sp, ), ), ), SizedBox( height: 15.h, ), // margin: EdgeInsets.only(top: 360.h), ], ), ); } @override Widget build(BuildContext context) { // var product; var color = const Color.fromRGBO(255, 209, 92, 0.1); return Scaffold( body: Stack( children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), ), child: Column( children: [ Expanded( child: ScrollSnapList( itemBuilder: _buildItemList, itemSize: 150, dynamicItemSize: true, onReachEnd: () { print('Done!'); }, itemCount: productList.length, // initialIndex: 0, onItemFocus: widget.onItemFocused), ), ], ), ), Container( margin: EdgeInsets.only(top: 474.h), color: Colors.amberAccent, width: 360.w, height: 58, child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: EdgeInsets.only(left: 30.w, top: 19.h), // child: Text(product.title), ) ], ), ), Container( margin: EdgeInsets.only(top: 193.h), // visible: activeColor == index ? true : false, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate(groceries.length, (index) { return Padding( padding: EdgeInsets.only(right: 2.w), child: AnimatedContainer( duration: const Duration(milliseconds: 300), curve: Curves.easeInCubic, height: indic_height(widget.index, index).h, width: indic_height(widget.index, index).w, decoration: BoxDecoration( shape: BoxShape.circle, color: index == widget.index ? const Color(0xfffa9746) : Colors.grey), ), ); }), ), ), SizedBox( height: 10.h, ), // ], ), ); } } class Product { final String imagePath; final String vectorPath; final String title; final int percent; Product( this.imagePath, this.vectorPath, this.title, this.percent, ); } GroceriesModel groceriesModelFromJson(String str) => GroceriesModel.fromJson(json.decode(str)); String groceriesModelToJson(GroceriesModel data) => json.encode(data.toJson()); class GroceriesModel { GroceriesModel({ required this.user_id, required this.groceryName, required this.totalQuantity, required this.totalQuantityUnits, }); String user_id; String groceryName; int totalQuantity; String totalQuantityUnits; factory GroceriesModel.fromJson(Map json) => GroceriesModel( user_id: json["user_id"], groceryName: json["groceriesName"], totalQuantity: json["totalQuantity"], totalQuantityUnits: json["totalQuantityUnits"], ); Map toJson() => { "user_id": user_id, "groceryName": groceryName, "totalQuantity": totalQuantity, "totalQuantityUnits": totalQuantityUnits, }; } class NetworkHandler { static final client = http.Client(); static final storage = FlutterSecureStorage(); static Future post(var body, String endpoint) async { print(buildUrl(endpoint)); print(body); var response = await client.post(buildUrl(endpoint), body: body, headers: {"Content-type": "application/json"}); print(response.statusCode); if (response.statusCode == 500) { print("Error ${response}"); } if (response.statusCode == 200) { return response.body; } return "Error"; } static var response; static Future get(String endpoint) async { try { var response = await client.get(buildUrl(endpoint)); // print(response.statusCode); // var data = jsonDecode(response.body); // print("data == > ${data}"); return response; } catch (e) { print(e); } return response; } static Future delete(String endpoint, Object body) async { try { var response = await client.delete(buildUrl(endpoint), body: body); return response.body; } catch (e) { print("Error occured in deleting grocery item"); print(e); } return response; } static buildUrl(String endpoint) { // https://wholesomeeten.gives String host = "http://localhost:4000/we/"; final apiPath = host + endpoint; print(apiPath); return Uri.parse(apiPath); } static Future storeToken(String token) async { await storage.write(key: "token", value: token); } static Future getToken() async { return await storage.read(key: "token"); } static Future storeUserId(String userId) async { await storage.write(key: "userId", value: userId); } static Future getuserId() async { return await storage.read(key: "userId"); } } final getStorage = GetStorage(); class GroceriesController extends GetxController { // TextEditingController user_id = TextEditingController(); TextEditingController groceriesName = TextEditingController(); TextEditingController totalQuantity = TextEditingController(); TextEditingController totalQuantityUnits = TextEditingController(); TextEditingController categoryController = TextEditingController(); // var groceriesName = "Ragi"; // var totalQuantity = 1; // var totalQuantityUnits = "kg"; Future sendGroceries() async { var userId = getStorage.read("userId"); print(userId); GroceriesModel groceriesModel = GroceriesModel( user_id: userId, groceryName: groceriesName.text, totalQuantity: int.parse(totalQuantity.text), totalQuantityUnits: totalQuantityUnits.text, ); String response = await NetworkHandler.post( groceriesModelToJson(groceriesModel), "groceries/calculate-nutrients"); //print(" json Decode body ==> ${jsonDecode(response)}"); print(response); return response; } void getUserGroceries() async { var userId = getStorage.read("userId"); var response = await NetworkHandler.get("groceries/get-allnutrietnts/$userId"); print("Response body ==> ${response.body}"); } Future deleteGrocery() async { print("Category is ${categoryController.text}"); var userId = getStorage.read("userId"); Object data = { "user_id": userId, "name": groceriesName.text, "foodCategory": categoryController.text, }; String response = await NetworkHandler.delete( "groceries/delete-user-grocery", data, ); print(response); return response; } } IndividualGrocery individualGroceryFromJson(String str) => IndividualGrocery.fromJson(json.decode(str)); String individualGroceryToJson(IndividualGrocery data) => json.encode(data.toJson()); class IndividualGrocery { IndividualGrocery({ required this.Energy, }); List Energy; factory IndividualGrocery.fromJson(Map json) => IndividualGrocery( Energy: List.from(json["Energy"].map((x) => x)), ); Map toJson() => { "Energy": List.from(Energy.map((x) => x)), }; } ```
exaby73 commented 1 year ago

@ravimandal06 The code sample you provided is very long. Please read the description of complete and minimal, reproducible example. You should only include code that is readable, and minimal to reproduce the issue, without the use of any 3rd party libraries. Please provide a minimal code sample when you can.

ravimandal06 commented 1 year ago

@exaby73 sir, when debugging it throw some error which is,

V/MiuiFrameworkFactory( 3368): get AllImpl object = android.common.MiuiFrameworkFactoryImpl@225285a

exaby73 commented 1 year ago

I would need a reproducible example and steps to reproduce to verify the issue. Please provide a complete and minimal, reproducible example

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.