import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'dart:convert' as convert;

class QrCode extends StatefulWidget {
  final String qrcode;

  const QrCode(this.qrcode, {Key key}) : super(key: key);

  @override
  _QrCodeState createState() => _QrCodeState();
}

class _QrCodeState extends State<QrCode> with AutomaticKeepAliveClientMixin {
  Uint8List src;

  @override
  void initState() {
    // TODO: implement initState
    src = convert.base64Decode(widget.qrcode);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(bottom: 12),
      width: 124,
      height: 124,
      // color: Colors.redAccent,
      child: Image.memory(src),
    );
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;
}
