box_in_camera 0.0.1
box_in_camera: ^0.0.1 copied to clipboard
A new flutter plugin project.
example/lib/main.dart
import 'dart:async';
import 'package:box_in_camera/box_in_camera.dart';
import 'package:flutter/material.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await BoxInCamera.initialize();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(debugShowCheckedModeBanner: false, home: MyHomePage());
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Box in Camera Example"),
backgroundColor: Colors.grey.shade800,
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BoxInCamera(),
),
).then((value) {
if (value != null) {
Timer(Duration(milliseconds: 30), () {
showDialog(
context: context,
builder: (context) => AlertDialog(
titlePadding:
EdgeInsets.fromLTRB(12.0, 12.0, 12.0, 0),
contentPadding: EdgeInsets.all(12.0),
title: Text("Croped Image"),
content: SizedBox(
width: 280.0,
height: 280.0,
child: Image.memory(value),
),
),
);
});
}
});
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Colors.grey.shade800,
),
),
child: Text("Start Camera"),
)
],
),
),
);
}
}