theme_patrol 0.0.1
theme_patrol: ^0.0.1 copied to clipboard
Keep an eyes on your app theme changes.
import 'package:flutter/material.dart';
import 'package:theme_patrol/theme_patrol.dart';
import 'package:flutter_circle_color_picker/flutter_circle_color_picker.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return ThemePatrol(
light: ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
dark: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
mode: ThemeMode.system,
builder: (context, theme) {
return MaterialApp(
title: 'Flutter Demo',
theme: theme.light,
darkTheme: theme.dark,
themeMode: theme.mode,
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
},
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: [
Switch(
value: ThemePatrol.of(context).isDarkMode,
onChanged: (selected) {
if (selected) {
ThemePatrol.of(context).darkMode();
} else {
ThemePatrol.of(context).lightMode();
}
},
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircleColorPicker(
initialColor: Theme.of(context).primaryColor,
onChanged: (color) => ThemePatrol.of(context).setColor(color),
size: const Size(240, 240),
strokeWidth: 4,
thumbSize: 36,
),
],
),
),// This trailing comma makes auto-formatting nicer for build methods.
);
}
}