flutter_highcontrast 0.0.2 copy "flutter_highcontrast: ^0.0.2" to clipboard
flutter_highcontrast: ^0.0.2 copied to clipboard

PlatformAndroidiOS
outdated

Flutter 获取设备是否开启高对比度模式

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter_highcontrast/flutter_highcontrast.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> {
  String _highcontrast = 'false';

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

  Future<void> init() async {
    FlutterHighcontrast();

    if(!mounted) return;

    setState(() {
      _highcontrast = FlutterHighcontrast().isHighContrastText(context).toString();
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('是否开启高对比度: $_highcontrast\n'),
        ),
      ),
    );
  }
}
0
likes
125
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter 获取设备是否开启高对比度模式

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on flutter_highcontrast

Packages that implement flutter_highcontrast