theyakka / qr.flutter

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.
https://pub.dev/packages/qr_flutter
BSD 3-Clause "New" or "Revised" License
718 stars 323 forks source link

QRCode generation for specific uses #219

Open FMorschel opened 6 months ago

FMorschel commented 6 months ago

Is your feature request related to a problem? Please describe. There is a site: https://br.qr-code-generator.com/ and some others that do the same. They have a list of different QRCodes that they support such as "V-Card", "WIFI", etc. Today if I'd like to do this with this package I'd have to manually implement these options.

Describe the solution you'd like I'd like an API for me to create these QRCodes for some of these options (like WIFI, V-Card, etc).

Describe alternatives you've considered Manually implement those defaults myself and give the result to the QR code generator API.

colmex commented 2 weeks ago

For anyone else that comes across this I managed to do it with this bit of code:

import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qr_flutter/qr_flutter.dart';

class WifiQRCode extends ConsumerWidget {
  final String ssid;
  final String password;
  final String encryption;

  const WifiQRCode({
    super.key,
    required this.ssid,
    required this.password,
    required this.encryption,
  });

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    // Format the WiFi QR data string
    final wifiData = 'WIFI:T:$encryption;S:$ssid;P:$password;;';

    return QrImageView(
      data: wifiData,
      version: QrVersions.auto,
    );
  }
}