image_picker_dialog 0.0.2 image_picker_dialog: ^0.0.2 copied to clipboard
image picker dialog.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:image_picker_dialog/image_picker_dialog.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final controller = GalleryController(
gallerySetting: const GallerySetting(
enableCamera: true,
maximum: 19,
requestType: RequestType.common,
actionButton: null,
albumColor: Colors.black,
albumTitleStyle: TextStyle(fontSize: 16),
),
panelSetting: const PanelSetting(),
headerSetting: const HeaderSetting(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
);
final notifier = ValueNotifier(<MediaEntity>[]);
@override
Widget build(BuildContext context) {
return GalleryViewWrapper(
controller: controller,
child: Scaffold(
backgroundColor: Colors.green,
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ValueListenableBuilder(
valueListenable: notifier,
builder: (ctx, values, _) => Wrap(
children: [
for (final value in values)
Image.memory(
value.bytes,
width: 40,
height: 40,
fit: BoxFit.cover,
),
],
)),
ValueListenableBuilder<List<MediaEntity>>(
valueListenable: notifier,
builder: (context, list, child) {
return GalleryViewField(
controller: controller,
selectedEntities: list,
onChanged: (entity, isRemoved) {
final value = notifier.value.toList();
if (isRemoved) {
value.remove(entity);
} else {
value.add(entity);
}
notifier.value = value;
},
onSubmitted: (list) async {
notifier.value = list;
},
child: child,
);
},
child: const Icon(Icons.image, color: Colors.black, size: 24.0),
),
],
),
),
),
);
}
}