Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.57 KB | None | 0 0
  1. import 'package:camera/camera.dart';
  2. import 'package:flutter/material.dart';
  3. import './settings.dart';
  4. import './Chats.dart';
  5. import './camera.dart';
  6. import 'dart:async';
  7.  
  8. List<CameraDescription> cameras;
  9.  
  10. Future<Null> main() async {
  11.   WidgetsFlutterBinding.ensureInitialized();
  12.   cameras = await availableCameras();
  13.   runApp(MyApp());
  14. }
  15.  
  16. class MyApp extends StatefulWidget {
  17.   final List<CameraDescription> cameras;
  18.   MyApp({this.cameras});
  19.  
  20.   @override
  21.   _MyAppState createState() => _MyAppState();
  22. }
  23.  
  24. class _MyAppState extends State <MyApp>{
  25.    int pagePressed=1;
  26.  
  27.   @override
  28.   Widget build(BuildContext context) {
  29. final page =[ CameraScreen(widget.cameras) ,Chats(), Settings()
  30.  ];
  31.      return MaterialApp(
  32.        debugShowCheckedModeBanner: false ,
  33.    home: Scaffold(
  34.  
  35.        body: page[pagePressed],
  36.  
  37.         bottomNavigationBar: BottomNavigationBar(
  38.           currentIndex: pagePressed ,
  39.          onTap: (int index){
  40.            setState(() {
  41.               pagePressed=index;
  42.             });
  43.           },
  44.          iconSize: 23,
  45.          selectedFontSize: 17 ,
  46.          unselectedFontSize: 13,
  47.           items: [
  48.             BottomNavigationBarItem(
  49.               icon: Icon(Icons.camera_alt),
  50.               title: Text('Camera'),
  51.               ),
  52.               BottomNavigationBarItem(
  53.               icon: Icon(Icons.chat_bubble),
  54.               title: Text('Chats')),
  55.               BottomNavigationBarItem(
  56.               icon: Icon(Icons.settings),
  57.               title: Text('Settings')),
  58.              
  59.           ],
  60.  
  61.    ),) );
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement