title: Flutter app error - getter 'value' was called on null
body: <p>I'm building one app where on top of Camera view I need to show something. Here is my code.</p>
  
  <pre><code>import 'dart:async';
  import 'package:flutter/material.dart';
  import 'package:camera/camera.dart';
  
  List&lt;CameraDescription&gt; cameras;
  
  void main() async {
    runApp(new MaterialApp(
      home: new CameraApp(),
    ));
  
  }
  
  class CameraApp extends StatefulWidget {
    @override
    _CameraAppState createState() =&gt; new _CameraAppState();
  }
  
  class _CameraAppState extends State&lt;CameraApp&gt; {
    CameraController controller;
    var cameras;
    bool cameraGot = false;
  
    Future&lt;Null&gt; getCamera() async {
      cameras = await availableCameras();
      setState(() {
        this.cameras = cameras;
        this.cameraGot = true;
      });
    }
  
    @override
    void initState() {
      getCamera();
      super.initState();
  
      if(this.cameraGot) {
        controller = new CameraController(this.cameras[0], ResolutionPreset.medium);
        controller.initialize().then((_) {
          if (!mounted) {
            return;
          }
          setState(() {});
        });
      }
  
    }
  
    @override
    void dispose() {
      controller?.dispose();
      super.dispose();
    }
  
    @override
    Widget build(BuildContext context) {
  
      // camera widget
      Widget cameraView = new Container(
        child: new Row(children: [
            new Expanded(
              child: new Column(
                  children: &lt;Widget&gt;[
                    new AspectRatio(
                      aspectRatio:
                          controller.value.aspectRatio,
                          child: new CameraPreview(controller)
                    )
                  ]
              ),
            )
        ])
      );
  
  
      return new Scaffold(
        body: new Stack(
          children: &lt;Widget&gt;[
            !this.controller.value.initialized ? new Container() : cameraView,
  
             // ---On top of Camera view add one mroe widget---
  
          ],
        ),
      );
    }
  }
  </code></pre>
  
  <p>Whenever I'm building the app I'm getting following error...</p>
  
  <pre><code>I/flutter ( 6911): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
  I/flutter ( 6911): The following NoSuchMethodError was thrown building CameraApp(dirty, state: _CameraAppState#b6034):
  I/flutter ( 6911): The getter 'value' was called on null.
  I/flutter ( 6911): Receiver: null
  I/flutter ( 6911): Tried calling: value
  </code></pre>
  
  <p>Can't able to fig. out what's the error. </p>