-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import 'package:camera/camera.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:henryckh/screens/home.dart'; | ||
|
||
void main() => | ||
runApp(MaterialApp(debugShowCheckedModeBanner: false, home: HomePage())); | ||
void main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
// Obtain a list of the available cameras on the device. | ||
final cameras = await availableCameras(); | ||
runApp( | ||
MaterialApp(debugShowCheckedModeBanner: false, home: HomePage(cameras))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,48 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:camera/camera.dart'; | ||
import 'package:henryckh/screens/camera.toolbar.dart'; | ||
|
||
class CameraApp extends StatefulWidget { | ||
CameraApp(this.camera); | ||
final List<CameraDescription> camera; | ||
|
||
@override | ||
_CameraAppState createState() => _CameraAppState(camera); | ||
} | ||
|
||
class _CameraAppState extends State<CameraApp> { | ||
CameraController controller; | ||
final List<CameraDescription> cameras; | ||
|
||
_CameraAppState(this.cameras); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
controller = CameraController(cameras[0], ResolutionPreset.max); | ||
controller.initialize().then((_) { | ||
if (!mounted) { | ||
return; | ||
} | ||
setState(() {}); | ||
}); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
controller?.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (!controller.value.isInitialized) { | ||
return Container(); | ||
} | ||
return MaterialApp( | ||
home: Center( | ||
child: Stack( | ||
children: [CameraPreview(controller), Toolbar()], | ||
))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class Toolbar extends StatefulWidget { | ||
@override | ||
_ToolbarState createState() => _ToolbarState(); | ||
} | ||
|
||
class _ToolbarState extends State<Toolbar> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
color: Colors.blue, | ||
width: MediaQuery.of(context).size.width, | ||
height: 56.0, | ||
child: Center( | ||
child: Text( | ||
"App Title", | ||
style: TextStyle(color: Colors.white, fontSize: 18.0), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters