insta_assets_picker 2.0.0 insta_assets_picker: ^2.0.0 copied to clipboard
An image picker similar with Instagram, supports multi picking, crop and aspect ratio.
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:insta_assets_picker_demo/pages/basic_picker.dart';
import 'package:insta_assets_picker_demo/pages/camera/camera_picker.dart';
import 'package:insta_assets_picker_demo/pages/camera/wechat_camera_picker.dart';
import 'package:insta_assets_picker_demo/pages/restorable_picker.dart';
import 'package:insta_assets_picker_demo/widgets/insta_picker_interface.dart';
const kDefaultColor = Colors.deepPurple;
late List<CameraDescription> _cameras;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
_cameras = await availableCameras();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Insta Assets Picker Demo',
// update to change the main theme of app + picker
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: kDefaultColor,
brightness: Brightness.dark,
),
cardTheme: const CardTheme(
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8)),
),
),
listTileTheme: const ListTileThemeData(
enableFeedback: true,
contentPadding: EdgeInsets.all(16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8)),
),
titleTextStyle: TextStyle(fontWeight: FontWeight.w600),
leadingAndTrailingTextStyle: TextStyle(fontSize: 24),
),
),
home: const PickersScreen(),
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
GlobalWidgetsLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
);
}
}
class PickersScreen extends StatelessWidget {
const PickersScreen({super.key});
@override
Widget build(BuildContext context) {
final List<InstaPickerInterface> pickers = [
const BasicPicker(),
const RestorablePicker(),
CameraPicker(camera: _cameras.first),
const WeChatCameraPicker(),
];
return Scaffold(
appBar: AppBar(title: const Text('Insta pickers')),
body: ListView.separated(
padding: const EdgeInsets.all(16),
itemBuilder: (BuildContext context, int index) {
final PickerDescription description = pickers[index].description;
return Card(
child: ListTile(
leading: Text(description.icon),
title: Text(description.label),
subtitle: description.description != null
? Text(description.description!)
: null,
trailing: const Icon(Icons.chevron_right_rounded),
onTap: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => pickers[index]),
),
),
);
},
separatorBuilder: (_, __) => const SizedBox(height: 4),
itemCount: pickers.length,
),
);
}
}