selfie_camera 0.0.7 copy "selfie_camera: ^0.0.7" to clipboard
selfie_camera: ^0.0.7 copied to clipboard

A simple camera plug-in, mainly suitable for selfie scenes, the current function is relatively single

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:selfie_camera/selfie_camera.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SelfieCamera.initialize(isLog: true);
  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(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  File? currentFile;

  void _incrementCounter() async {
    var file = await SelfieCamera.selfieCameraFile(
      context,
      imageResolution: ImageResolution.max,
      defaultCameraType: CameraType.front,
      defaultFlashType: CameraFlashType.off,
      imageScale: ImageScale.big,
      showCameraTypeControl: false,
    );
    if (file != null) {
      setState(() {
        currentFile = File(file.path);
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text("selfie"),
      ),
      body: Center(
        child: Container(
          width: double.infinity,
          color: Colors.blueAccent,
          child: currentFile != null
              ? Image.file(
                  currentFile!,
                  fit: BoxFit.fitWidth,
                )
              : null,
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
1
likes
140
pub points
0%
popularity

Publisher

unverified uploader

A simple camera plug-in, mainly suitable for selfie scenes, the current function is relatively single

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

camera, flutter, image_editor, plugin_platform_interface

More

Packages that depend on selfie_camera