import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:womenentrepreneur/configs/app_route.dart';
Future<String?> appRadioBottomSheet(
{required BuildContext context,
required String defaultValue,
required String title,
required List<String> values}) async {
String? selectValue;
String firstValue = defaultValue;
await showModalBottomSheet(
isScrollControlled: true,
useSafeArea: true,
context: context,
builder: (context) => StatefulBuilder(
builder: (context, setState) => Wrap(
children: [
ListTile(
title: Text(title),
trailing: InkWell(
onTap: () {
selectValue = defaultValue;
AppRoutes.pop(context);
},
child: const Icon(Icons.done)),
),
values.isEmpty
? const SizedBox()
: ListView.builder(
shrinkWrap: true,
itemCount: values.length,
itemBuilder: (context, index) =>
RadioListTile.adaptive(
title: Text(values[index]),
value: values[index],
groupValue: defaultValue,
onChanged: (value) {
setState(() {
defaultValue = value.toString();
});
},
),
),
],
)));
return selectValue ?? firstValue;
}
Future<XFile?> appPickImage(BuildContext context) async {
XFile? photo;
final ImagePicker picker = ImagePicker();
await showModalBottomSheet(
context: context,
builder: (_) => Wrap(
spacing: 15,
children: [
const SizedBox(
height: 10,
),
ListTile(
onTap: () async {
await picker.pickImage(source: ImageSource.gallery).then((value) {
if (value != null) {
photo = value;
}
Navigator.pop(context, photo);
});
},
contentPadding: const EdgeInsets.symmetric(horizontal: 30),
leading: const Icon(CupertinoIcons.photo),
title: const Text("From Gallery"),
),
ListTile(
onTap: () async {
await picker.pickImage(source: ImageSource.camera).then((value) {
if (value != null) {
photo = value;
}
Navigator.pop(context, photo);
});
},
contentPadding: const EdgeInsets.symmetric(horizontal: 30),
leading: const Icon(CupertinoIcons.camera),
title: const Text("Take a Picture"),
),
const SizedBox(
height: 10,
),
],
),
);
return photo;
}
import 'package:image_picker/image_picker.dart';
import 'package:womenentrepreneur/configs/app_route.dart';
Future<String?> appRadioBottomSheet(
{required BuildContext context,
required String defaultValue,
required String title,
required List<String> values}) async {
String? selectValue;
String firstValue = defaultValue;
await showModalBottomSheet(
isScrollControlled: true,
useSafeArea: true,
context: context,
builder: (context) => StatefulBuilder(
builder: (context, setState) => Wrap(
children: [
ListTile(
title: Text(title),
trailing: InkWell(
onTap: () {
selectValue = defaultValue;
AppRoutes.pop(context);
},
child: const Icon(Icons.done)),
),
values.isEmpty
? const SizedBox()
: ListView.builder(
shrinkWrap: true,
itemCount: values.length,
itemBuilder: (context, index) =>
RadioListTile.adaptive(
title: Text(values[index]),
value: values[index],
groupValue: defaultValue,
onChanged: (value) {
setState(() {
defaultValue = value.toString();
});
},
),
),
],
)));
return selectValue ?? firstValue;
}
Future<XFile?> appPickImage(BuildContext context) async {
XFile? photo;
final ImagePicker picker = ImagePicker();
await showModalBottomSheet(
context: context,
builder: (_) => Wrap(
spacing: 15,
children: [
const SizedBox(
height: 10,
),
ListTile(
onTap: () async {
await picker.pickImage(source: ImageSource.gallery).then((value) {
if (value != null) {
photo = value;
}
Navigator.pop(context, photo);
});
},
contentPadding: const EdgeInsets.symmetric(horizontal: 30),
leading: const Icon(CupertinoIcons.photo),
title: const Text("From Gallery"),
),
ListTile(
onTap: () async {
await picker.pickImage(source: ImageSource.camera).then((value) {
if (value != null) {
photo = value;
}
Navigator.pop(context, photo);
});
},
contentPadding: const EdgeInsets.symmetric(horizontal: 30),
leading: const Icon(CupertinoIcons.camera),
title: const Text("Take a Picture"),
),
const SizedBox(
height: 10,
),
],
),
);
return photo;
}
Comments
Post a Comment