anchor.diff:  import 'package:permission_handler/permission_handler.dart';
   import 'package:provider/provider.dart';
   
  -class ScanditScanner extends StatefulWidget {
  -  @override
  -  _ScanditScannerState createState() => _ScanditScannerState();
  -}
  -
  -class _ScanditScannerState extends State<ScanditScanner> {
  -  String _message = '';
  -  ScanditController _controller;
  -  bool hasScanned;
  -  bool hasSubmitted;
  -  bool didError;
  -  String licenseKey;
  -  BarcodeService _barcodeService = new BarcodeService();
  +class ScanditScanner extends StatelessWidget {
  +  ScannerDataProvider _scannerDataProvider;
     UserDataProvider _userDataProvider;
     set userDataProvider(UserDataProvider value) => _userDataProvider = value;
  -  String _barcode;
  -  String _errorText;
  -  bool isLoading;
  -  bool isDuplicate;
  -  bool successfulSubmission;
  -  bool isValidBarcode;
  -  PermissionStatus _cameraPermissionsStatus = PermissionStatus.undetermined;
  -  List<String> scannedCodes = new List<String>();
  -
  -  Future _requestCameraPermissions() async {
  -    var status = await Permission.camera.status;
  -    if (!status.isGranted) {
  -      status = await Permission.camera.request();
  -    }
  -
  -    if (_cameraPermissionsStatus != status) {
  -      setState(() {
  -        _cameraPermissionsStatus = status;
  -      });
  -    }
  -  }
  -
  -  @override
  -  void initState() {
  -    super.initState();
  -    hasScanned = false;
  -    hasSubmitted = false;
  -    didError = false;
  -    successfulSubmission = false;
  -    isLoading = false;
  -    isDuplicate = false;
  -    isValidBarcode = true;
  -    _errorText = "Something went wrong, please try again.";
  -
  -    WidgetsBinding.instance
  -        .addPostFrameCallback((_) => _requestCameraPermissions());
  -  }
   
     @override
     Widget build(BuildContext context) {
       _userDataProvider = Provider.of<UserDataProvider>(context);
  -    if (Theme.of(context).platform == TargetPlatform.iOS) {
  -      licenseKey = "SCANDIT_NATIVE_LICENSE_IOS_PH";
  -    } else if (Theme.of(context).platform == TargetPlatform.android) {
  -      licenseKey = "SCANDIT_NATIVE_LICENSE_ANDROID_PH";
  -    }
  +    _scannerDataProvider = Provider.of<ScannerDataProvider>(context);
  +    _scannerDataProvider.requestCameraPermissions();
       return Scaffold(
         appBar: PreferredSize(
           preferredSize: Size.fromHeight(42),
  
positive.code:           " You can view your results by logging in to MyUCSDChart.");
      }
    }
  
    Future<void> _handleBarcodeResult(BarcodeResult result) async {
      this.setState(() {
        hasScanned = true;
        _barcode = result?.data;
        isLoading = true;
      });
  
      try {
        var accessTokenExpiration =
            _userDataProvider?.authenticationModel?.expiration;
        var nowTime = (DateTime.now().millisecondsSinceEpoch / 1000).round();
        var timeDiff = accessTokenExpiration - nowTime;
        var tokenExpired = timeDiff <= 0 ? true : false;
        var isLoggedIn =
            Provider.of<UserDataProvider>(context, listen: false).isLoggedIn;
        var validToken = false;
  
        if (isLoggedIn) {
          if (tokenExpired) {
            if (await _userDataProvider.silentLogin()) {
              validToken = true;
            }
          } else {
            validToken = true;
          }
  
          if (validToken) {
            var results = await _barcodeService.uploadResults({
              "Content-Type": "application/json",
              'Authorization':
                  'Bearer ${_userDataProvider?.authenticationModel?.accessToken}'
            }, {
              'barcode': _barcode
            });
  
            if (results) {
              this.setState(() {
                successfulSubmission = true;
                didError = false;
                isLoading = false;
              });
            } else {
              this.setState(() {
                successfulSubmission = false;
                didError = true;
                isLoading = false;
              });
  
              if (_barcodeService.error
                  .contains(ErrorConstants.duplicateRecord)) {
                this.setState(() {
                  _errorText = ScannerConstants.duplicateRecord;
                  isDuplicate = true;
                });
              } else if (_barcodeService.error
                  .contains(ErrorConstants.invalidMedia)) {
                this.setState(() {
                  _errorText = ScannerConstants.invalidMedia;
                  isValidBarcode = false;
                });
              } else {
                this.setState(() {
                  _errorText = ScannerConstants.barcodeError;
                });
              }
            }
          } else {
            this.setState(() {
              successfulSubmission = false;
              didError = true;
              isLoading = false;
              _errorText = ScannerConstants.invalidToken;
            });
          }
        } else {
          this.setState(() {
            successfulSubmission = false;
            didError = true;
            isLoading = false;
            _errorText = ScannerConstants.loggedOut;
          });
        }
      } catch (e) {
        this.setState(() {
          successfulSubmission = false;
          didError = true;
          isLoading = false;
          _errorText = ScannerConstants.unknownError;
        });
      }
    }
  }
  
negative.code:               ),
                Text("Scan sent at: " + scanTime,
                    style: TextStyle(color: Theme.of(context).iconTheme.color)),
                Text("Scanned value: " + _scannerDataProvider.barcode,
                    style: TextStyle(color: Theme.of(context).iconTheme.color)),
              ])),
            ),
  