night_color 0.0.2
night_color: ^0.0.2 copied to clipboard
Night Color adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night.
import 'package:flutter/material.dart';
import 'package:night_color/night_color.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool enabled = true;
@override
Widget build(BuildContext context) {
return NightColor(
enabled: enabled,
child: Scaffold(
appBar: AppBar(
title: const Text('Night Color Demo Home Page'),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"test night color",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
Switch(
value: enabled,
onChanged: (value) {
setState(() {
enabled = value;
});
},
)
],
),
),
),
);
}
}