Advertisement
anik11556

fuctionPass

Nov 12th, 2023
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1.  
  2. Navigator.push(
  3. context,
  4. CupertinoPageRoute(
  5. builder: (_) => TakeImage(
  6. onImageSelected: (String imagePath) {
  7.  
  8. setState(() {
  9. path = imagePath;
  10. });
  11.  
  12. print('getting the path: $imagePath');
  13. },
  14. isProfilePhoto: false, // Provide the flag value here
  15. ),
  16. ));
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. import 'package:flutter/cupertino.dart';
  25. import 'package:flutter/material.dart';
  26.  
  27. import '../Components/Common/ImagePickBox.dart';
  28.  
  29. class TakeImage extends StatefulWidget {
  30. final Function(String) onImageSelected;
  31. final bool isProfilePhoto;
  32.  
  33. const TakeImage({Key? key, required this.onImageSelected, required this.isProfilePhoto}) : super(key: key);
  34.  
  35.  
  36.  
  37. @override
  38. State<TakeImage> createState() => _TakeImageState();
  39. }
  40.  
  41. class _TakeImageState extends State<TakeImage> {
  42.  
  43. String path="null";
  44. @override
  45. Widget build(BuildContext context) {
  46. return Scaffold(
  47. appBar: AppBar(
  48. actions: [
  49. IconButton(onPressed: (){
  50.  
  51. widget.onImageSelected(path);
  52. Navigator.pop(context);
  53. }, icon: Icon(Icons.done))
  54. ],
  55. ),
  56. body: ImagePickBox(
  57. onImageSelected: (String imagePath) {
  58. setState(() => path = imagePath);
  59. // Handle the selected image path here
  60. print('Received Image Path: $imagePath');
  61. }, isProfilePhoto: false,
  62. ) ,
  63. );
  64. }
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement