instagram_crop_images_video 1.0.1 instagram_crop_images_video: ^1.0.1 copied to clipboard
A Flutter package for cropping images with Instagram-like features such as square aspect ratio and filters.
import 'package:camera/camera.dart';
import 'package:example/pages/camera/camera_picker.dart';
import 'package:example/widgets/insta_picker_interface.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'pages/camera/wechat_camera_picker.dart';
import 'pages/restorable_picker.dart';
import 'pages/stateless_pickers.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 SinglePicker(),
const MultiplePicker(),
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,
),
);
}
}