get_web_renderer 0.0.1+3 copy "get_web_renderer: ^0.0.1+3" to clipboard
get_web_renderer: ^0.0.1+3 copied to clipboard

outdated

Get current web renderer

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:get_web_renderer/get_web_renderer.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  CurrentRenderer? _currentRenderer;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    final currentRenderer = getCurrentRenderer;

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _currentRenderer = currentRenderer;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Current Web Renderer'),
        ),
        body: _currentRenderer == null
            ? const CircularProgressIndicator()
            : Center(
                child: Text('This device using $_currentRenderer renderer'),
              ),
      ),
    );
  }
}