Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azkadev/camera_universal
https://github.com/azkadev/camera_universal
android camera dart flutter ios linux web windows
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/azkadev/camera_universal
- Owner: azkadev
- License: mit
- Created: 2023-01-30T20:38:30.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-24T07:06:23.000Z (7 months ago)
- Last Synced: 2024-12-15T16:06:21.322Z (9 days ago)
- Topics: android, camera, dart, flutter, ios, linux, web, windows
- Language: Dart
- Homepage:
- Size: 341 KB
- Stars: 354
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Camera Universal
## Install
```bash
flutter pub add camera_universal
```## Quickstart
```dart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:camera_universal/camera_universal.dart';
void main(List args) async {
WidgetsFlutterBinding.ensureInitialized();
runApp(
const MaterialApp(
home: MainApp(),
),
);
}
class MainApp extends StatefulWidget {
const MainApp({
super.key,
});
@override
State createState() => _MainAppState();
}
class _MainAppState extends State {
CameraController cameraController = CameraController();
@override
void initState() {
super.initState();
task();
}
Future task() async {
await cameraController.initializeCameras();
await cameraController.initializeCamera(
setState: setState,
);
await cameraController.activateCamera(
setState: setState,
mounted: () {
return mounted;
},
);
}
@override
void dispose() {
cameraController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Camera(
cameraController: cameraController,
onCameraNotInit: (context) {
return const SizedBox.shrink();
},
onCameraNotSelect: (context) {
return const SizedBox.shrink();
},
onCameraNotActive: (context) {
return const SizedBox.shrink();
},
onPlatformNotSupported: (context) {
return const SizedBox.shrink();
},
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
if (kDebugMode) {
print(
cameraController.action_change_camera(
camera_id: 1,
setState: setState,
mounted: () {
return mounted;
},
onCameraNotInit: () {},
onCameraNotSelect: () {},
onCameraNotActive: () {},
),
);
}
},
child: const Icon(
Icons.add_circle_outline_sharp,
),
),
);
}
}
```