| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import 'package:flutter/material.dart';
- import 'dart:async';
- import 'package:flutter/services.dart';
- import 'package:flutter_ali_camera/flutter_ali_camera.dart';
- void main() async {
- WidgetsFlutterBinding.ensureInitialized();
- await FlutterAliCameraController.initializeSdk();
- runApp(MyApp());
- }
- class MyApp extends StatefulWidget {
- @override
- _MyAppState createState() => _MyAppState();
- }
- class _MyAppState extends State<MyApp> {
- FlutterAliCameraController _controller = FlutterAliCameraController();
- double value = 0;
- @override
- void initState() {
- super.initState();
- initPlatform();
- }
- Future<void> initPlatform() async {
- await _controller.create();
- setState(() {});
- }
- void _onPlatformViewCreated() {
- }
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: Scaffold(
- backgroundColor: Colors.white,
- appBar: AppBar(
- title: const Text('Plugin example app'),
- ),
- body: Column(
- children: <Widget>[
- SizedBox(
- width: double.maxFinite,
- height: 200,
- child: _controller.buildView(_onPlatformViewCreated),
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: <Widget>[
- IconButton(icon: Icon(Icons.play_arrow, size: 26,), onPressed: () {
- _controller.startPreview();
- }),
- IconButton(icon: Icon(Icons.pause, size: 26,), onPressed: () {
- _controller.stopPreview();
- }),
- ],
- ),
- SizedBox(height: 5,),
- Slider(value: value, max: 100, onChanged: (value) {
- _controller.setBeauty(value.toInt());
- setState(() {
- this.value = value;
- });
- }),
- ],
- ),
- ),
- );
- }
- }
|