diff --git a/analysis_options.yaml b/analysis_options.yaml index 5cd18bde2..c00177a5f 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,6 +1,7 @@ -include: package:lints/recommended.yaml +include: package:flutter_lints/flutter.yaml linter: rules: prefer_const_constructors: true prefer_const_declarations: true + require_trailing_commas: true diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index e69de29bb..c00177a5f 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -0,0 +1,7 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: + prefer_const_constructors: true + prefer_const_declarations: true + require_trailing_commas: true diff --git a/example/lib/main.dart b/example/lib/main.dart index e8c8379b0..5614b80b0 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -3,17 +3,19 @@ import 'package:yaru/yaru.dart'; import 'package:yaru_example/view/home_page.dart'; void main() { - runApp(MyApp()); + runApp(const MyApp()); } class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return MaterialApp( home: Builder( builder: (context) => YaruTheme( data: AppTheme.of(context), - child: HomePage(), + child: const HomePage(), ), ), debugShowCheckedModeBanner: false, @@ -23,7 +25,11 @@ class MyApp extends StatelessWidget { class AppTheme { static YaruThemeData of(BuildContext context) { - return SharedAppData.getValue(context, 'theme', () => YaruThemeData()); + return SharedAppData.getValue( + context, + 'theme', + () => const YaruThemeData(), + ); } static void apply( diff --git a/example/lib/view/color_disk.dart b/example/lib/view/color_disk.dart index 28ecc6f82..c5477cfd6 100644 --- a/example/lib/view/color_disk.dart +++ b/example/lib/view/color_disk.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; class ColorDisk extends StatelessWidget { - const ColorDisk( - {Key? key, - required this.onPressed, - required this.color, - required this.selected}) - : super(key: key); + const ColorDisk({ + Key? key, + required this.onPressed, + required this.color, + required this.selected, + }) : super(key: key); final VoidCallback onPressed; final Color color; @@ -22,10 +22,12 @@ class ColorDisk extends StatelessWidget { style: TextButton.styleFrom( padding: const EdgeInsets.all(0), shape: CircleBorder( - side: BorderSide( - color: selected - ? Theme.of(context).primaryColor - : Colors.transparent)), + side: BorderSide( + color: selected + ? Theme.of(context).primaryColor + : Colors.transparent, + ), + ), ), onPressed: onPressed, child: SizedBox( @@ -33,7 +35,9 @@ class ColorDisk extends StatelessWidget { width: 20, child: DecoratedBox( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100), color: color), + borderRadius: BorderRadius.circular(100), + color: color, + ), ), ), ), diff --git a/example/lib/view/colors_view.dart b/example/lib/view/colors_view.dart index 3af1f552b..55f5faf81 100644 --- a/example/lib/view/colors_view.dart +++ b/example/lib/view/colors_view.dart @@ -1,54 +1,61 @@ import 'package:flutter/material.dart'; + import 'package:yaru_colors/yaru_colors.dart'; class ColorsView extends StatelessWidget { + const ColorsView({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return ListView( - padding: EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15.0), children: [ Text('Accent Colors', style: Theme.of(context).textTheme.headline4), const SizedBox(height: 15.0), Row( children: [ Expanded(child: colorPaletteExample('orange', YaruColors.orange)), - SizedBox(width: 25.0), + const SizedBox(width: 25.0), Expanded(child: colorPaletteExample('olive', YaruColors.olive)), - SizedBox(width: 25.0), + const SizedBox(width: 25.0), Expanded(child: colorPaletteExample('bark', YaruColors.bark)), ], ), - Divider(height: 50.0), + const Divider(height: 50.0), Row( children: [ Expanded( - child: colorPaletteExample('viridian', YaruColors.viridian)), - SizedBox(width: 25.0), + child: colorPaletteExample('viridian', YaruColors.viridian), + ), + const SizedBox(width: 25.0), Expanded(child: colorPaletteExample('purple', YaruColors.purple)), - SizedBox(width: 25.0), + const SizedBox(width: 25.0), Expanded(child: colorPaletteExample('red', YaruColors.red)), ], ), - Divider(height: 50.0), + const Divider(height: 50.0), Row( children: [ Expanded(child: colorPaletteExample('blue', YaruColors.blue)), - SizedBox(width: 25.0), + const SizedBox(width: 25.0), Expanded(child: colorPaletteExample('magenta', YaruColors.magenta)), - SizedBox(width: 25.0), + const SizedBox(width: 25.0), Expanded(child: colorPaletteExample('sage', YaruColors.sage)), ], ), - Divider(height: 50.0), + const Divider(height: 50.0), Row( children: [ Expanded( - child: colorPaletteExample( - 'prussianGreen', YaruColors.prussianGreen)), - SizedBox(width: 25.0), - Spacer(), - SizedBox(width: 25.0), - Spacer(), + child: colorPaletteExample( + 'prussianGreen', + YaruColors.prussianGreen, + ), + ), + const SizedBox(width: 25.0), + const Spacer(), + const SizedBox(width: 25.0), + const Spacer(), ], ), const SizedBox(height: 15.0), @@ -57,32 +64,41 @@ class ColorsView extends StatelessWidget { Row( children: [ Expanded( - child: - colorPaletteExample('kubuntuBlue', YaruColors.kubuntuBlue)), - SizedBox(width: 25.0), + child: colorPaletteExample('kubuntuBlue', YaruColors.kubuntuBlue), + ), + const SizedBox(width: 25.0), Expanded( - child: - colorPaletteExample('lubuntuBlue', YaruColors.lubuntuBlue)), - SizedBox(width: 25.0), + child: colorPaletteExample('lubuntuBlue', YaruColors.lubuntuBlue), + ), + const SizedBox(width: 25.0), Expanded( - child: colorPaletteExample( - 'ubuntuBudgieBlue', YaruColors.ubuntuBudgieBlue)), + child: colorPaletteExample( + 'ubuntuBudgieBlue', + YaruColors.ubuntuBudgieBlue, + ), + ), ], ), - Divider(height: 50.0), + const Divider(height: 50.0), Row( children: [ Expanded( - child: colorPaletteExample( - 'ubuntuMateGreen', YaruColors.ubuntuMateGreen)), - SizedBox(width: 25.0), + child: colorPaletteExample( + 'ubuntuMateGreen', + YaruColors.ubuntuMateGreen, + ), + ), + const SizedBox(width: 25.0), Expanded( - child: colorPaletteExample( - 'ubuntuStudioBlue', YaruColors.ubuntuStudioBlue)), - SizedBox(width: 25.0), + child: colorPaletteExample( + 'ubuntuStudioBlue', + YaruColors.ubuntuStudioBlue, + ), + ), + const SizedBox(width: 25.0), Expanded( - child: - colorPaletteExample('xubuntuBlue', YaruColors.xubuntuBlue)), + child: colorPaletteExample('xubuntuBlue', YaruColors.xubuntuBlue), + ), ], ), ], @@ -90,50 +106,48 @@ class ColorsView extends StatelessWidget { } Widget colorPaletteExample(String colorName, MaterialColor color) { - Map _color = {colorName: color}; - int _shade = 50; - TextStyle _textStyle(int _shade) => TextStyle( - color: (_color.values.first[_shade]!.computeLuminance() > 0.4) + Map colorEntry = {colorName: color}; + int shade = 50; + TextStyle textStyle(int shade) => TextStyle( + color: (colorEntry.values.first[shade]!.computeLuminance() > 0.4) ? Colors.black : Colors.white, fontSize: 9.0, ); - List _colorItem = []; + List colorItem = []; for (int i = 1; i <= 10; i++) { - _colorItem.add(Container( - height: 40.0, - color: _color.values.first[_shade], - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 10, - child: Text( - _color.keys.first + '[$_shade]', - style: _textStyle(_shade), + colorItem.add( + Container( + height: 40.0, + color: colorEntry.values.first[shade], + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 10, + child: Text( + '${colorEntry.keys.first}[$shade]', + style: textStyle(shade), + ), ), - ), - Expanded( - flex: 4, - child: Text( - '#' + - _color.values.first[_shade]!.value - .toRadixString(16) - .substring(2) - .toUpperCase(), - style: _textStyle(_shade), + Expanded( + flex: 4, + child: Text( + '#${colorEntry.values.first[shade]!.value.toRadixString(16).substring(2).toUpperCase()}', + style: textStyle(shade), + ), ), - ), - ], + ], + ), ), ), - )); - _shade = i * 100; + ); + shade = i * 100; } return Column( - children: _colorItem, + children: colorItem, ); } } diff --git a/example/lib/view/controls_view.dart b/example/lib/view/controls_view.dart index e08ca6593..d3f857691 100644 --- a/example/lib/view/controls_view.dart +++ b/example/lib/view/controls_view.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; class ControlsView extends StatefulWidget { + const ControlsView({super.key}); + @override State createState() => _ControlsViewState(); } @@ -19,24 +21,27 @@ class _ControlsViewState extends State Widget build(BuildContext context) { return Column( children: [ - TabBar(controller: tabController, tabs: [ - Padding( - padding: const EdgeInsets.all(12.0), - child: Text('Buttons'), - ), - Padding( - padding: const EdgeInsets.all(12.0), - child: Text('Checks'), - ), - Padding( - padding: const EdgeInsets.all(12.0), - child: Text('Switches'), - ), - Padding( - padding: const EdgeInsets.all(12.0), - child: Text('Progress'), - ) - ]), + TabBar( + controller: tabController, + tabs: const [ + Padding( + padding: EdgeInsets.all(12.0), + child: Text('Buttons'), + ), + Padding( + padding: EdgeInsets.all(12.0), + child: Text('Checks'), + ), + Padding( + padding: EdgeInsets.all(12.0), + child: Text('Switches'), + ), + Padding( + padding: EdgeInsets.all(12.0), + child: Text('Progress'), + ) + ], + ), Expanded( child: TabBarView( controller: tabController, @@ -47,49 +52,55 @@ class _ControlsViewState extends State children: [ Padding( padding: const EdgeInsets.all(8.0), - child: Row(children: [ - SizedBox( - width: 95, - child: TextButton( - onPressed: () => print('FlatButton'), - child: const Text('Click me!'), + child: Row( + children: [ + SizedBox( + width: 95, + child: TextButton( + onPressed: () {}, + child: const Text('Click me!'), + ), ), - ), - const SizedBox(width: 15), - TextButton( - onPressed: null, - child: const Text("Can't click me!"), - autofocus: true, - ), - ]), + const SizedBox(width: 15), + const TextButton( + onPressed: null, + autofocus: true, + child: Text("Can't click me!"), + ), + ], + ), ), Padding( padding: const EdgeInsets.all(8.0), - child: Row(children: [ - OutlinedButton( - onPressed: () => print('OutlinedButton'), - child: const Text('Click me!'), - ), - const SizedBox(width: 15), - OutlinedButton( - onPressed: null, - child: const Text("Can't click me!"), - ), - ]), + child: Row( + children: [ + OutlinedButton( + onPressed: () {}, + child: const Text('Click me!'), + ), + const SizedBox(width: 15), + const OutlinedButton( + onPressed: null, + child: Text("Can't click me!"), + ), + ], + ), ), Padding( padding: const EdgeInsets.all(8.0), - child: Row(children: [ - ElevatedButton( - onPressed: () => print('RaisedButton'), - child: const Text('Click me!'), - ), - const SizedBox(width: 15), - ElevatedButton( - onPressed: null, - child: const Text("Can't click me!"), - ), - ]), + child: Row( + children: [ + ElevatedButton( + onPressed: () {}, + child: const Text('Click me!'), + ), + const SizedBox(width: 15), + const ElevatedButton( + onPressed: null, + child: Text("Can't click me!"), + ), + ], + ), ), Padding( padding: const EdgeInsets.all(8.0), @@ -98,14 +109,22 @@ class _ControlsViewState extends State child: Row( children: [ ToggleButtons( - children: [Text('Yes'), Text('No'), Text('No')], - isSelected: [true, false, false], + isSelected: const [true, false, false], onPressed: (v) {}, + children: const [ + Text('Yes'), + Text('No'), + Text('No') + ], ), const SizedBox(width: 15), ToggleButtons( - children: [Text('Yes'), Text('No'), Text('No')], - isSelected: [true, false, false], + isSelected: const [true, false, false], + children: const [ + Text('Yes'), + Text('No'), + Text('No') + ], ), ], ), @@ -116,16 +135,21 @@ class _ControlsViewState extends State child: Row( children: [ DropdownButton( - onChanged: (value) => - print('DropdownButton $value'), + onChanged: (value) {}, value: 1, - items: >[ + items: const >[ DropdownMenuItem( - value: 1, child: const Text('One')), + value: 1, + child: Text('One'), + ), DropdownMenuItem( - value: 2, child: const Text('Two')), + value: 2, + child: Text('Two'), + ), DropdownMenuItem( - value: 3, child: const Text('Three')), + value: 3, + child: Text('Three'), + ), ], ), ], @@ -134,28 +158,29 @@ class _ControlsViewState extends State Row( children: [ IconButton( - splashRadius: 20, - onPressed: () => showDialog( - context: context, - builder: (context) => SimpleDialog( - title: - Center(child: Text('Dialog Title')), - titlePadding: EdgeInsets.only(top: 15), - children: [ - Center( - child: Column( - children: [ - for (var i = 0; i < 10; i++) - Padding( - padding: - const EdgeInsets.all(8.0), - child: Text('Content'), - ), - ], - )), - ], - )), - icon: Icon(Icons.account_circle_rounded)), + splashRadius: 20, + onPressed: () => showDialog( + context: context, + builder: (context) => SimpleDialog( + title: const Center(child: Text('Dialog Title')), + titlePadding: const EdgeInsets.only(top: 15), + children: [ + Center( + child: Column( + children: [ + for (var i = 0; i < 10; i++) + const Padding( + padding: EdgeInsets.all(8.0), + child: Text('Content'), + ), + ], + ), + ), + ], + ), + ), + icon: const Icon(Icons.account_circle_rounded), + ), ], ) ], @@ -163,40 +188,44 @@ class _ControlsViewState extends State ), ListView( shrinkWrap: true, - padding: EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15.0), children: [ Row( children: [ Column( children: [ - Text('Checkbox'), + const Text('Checkbox'), Row( children: [ Checkbox(value: true, onChanged: (_) {}), Checkbox(value: false, onChanged: (_) {}), - Checkbox(value: true, onChanged: null), - Checkbox(value: false, onChanged: null), + const Checkbox(value: true, onChanged: null), + const Checkbox(value: false, onChanged: null), ], ), - Text('Radio'), + const Text('Radio'), Row( children: [ Radio( - value: true, - groupValue: true, - onChanged: (_) {}), - Radio( - value: false, - groupValue: true, - onChanged: (_) {}), - Radio( - value: true, - groupValue: true, - onChanged: null), + value: true, + groupValue: true, + onChanged: (_) {}, + ), Radio( - value: false, - groupValue: true, - onChanged: null), + value: false, + groupValue: true, + onChanged: (_) {}, + ), + const Radio( + value: true, + groupValue: true, + onChanged: null, + ), + const Radio( + value: false, + groupValue: true, + onChanged: null, + ), ], ), ], @@ -224,21 +253,21 @@ class _ControlsViewState extends State ], ), Row( - children: [ + children: const [ Switch( value: true, onChanged: null, ), - const Text('Disabled Yes'), + Text('Disabled Yes'), ], ), Row( - children: [ + children: const [ Switch( value: false, onChanged: null, ), - const Text('Disabled No'), + Text('Disabled No'), ], ), ], @@ -249,13 +278,13 @@ class _ControlsViewState extends State Padding( padding: const EdgeInsets.all(18.0), child: Row( - children: [ + children: const [ CircularProgressIndicator(), ], ), ), - Padding( - padding: const EdgeInsets.all(18.0), + const Padding( + padding: EdgeInsets.all(18.0), child: LinearProgressIndicator(), ), ], diff --git a/example/lib/view/fonts_view.dart b/example/lib/view/fonts_view.dart index 9a96ef74b..58b0cb3d3 100644 --- a/example/lib/view/fonts_view.dart +++ b/example/lib/view/fonts_view.dart @@ -1,10 +1,12 @@ import 'package:flutter/material.dart'; class FontsView extends StatelessWidget { + const FontsView({super.key}); + @override Widget build(BuildContext context) { return ListView( - padding: EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15.0), children: [ Text( 'headline1', diff --git a/example/lib/view/home_page.dart b/example/lib/view/home_page.dart index 3ba083033..9c3271eb5 100644 --- a/example/lib/view/home_page.dart +++ b/example/lib/view/home_page.dart @@ -11,11 +11,11 @@ class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override - _HomePageState createState() => _HomePageState(); + HomePageState createState() => HomePageState(); } -class _HomePageState extends State { - _HomePageState(); +class HomePageState extends State { + HomePageState(); int _counter = 0; void incrementCounter() { @@ -27,15 +27,16 @@ class _HomePageState extends State { } final textController = TextEditingController( - text: - 'My code fails, I do not know why.\nMy code works, I do not know why.\nText in other scripts: Tamaziɣt Taqbaylit, 中文(简体), Čeština, Беларуская, Ελληνικά, עברית, Русский, བོད་ཡིག, Norsk bokmål.'); + text: + 'My code fails, I do not know why.\nMy code works, I do not know why.\nText in other scripts: Tamaziɣt Taqbaylit, 中文(简体), Čeština, Беларуская, Ελληνικά, עברית, Русский, བོད་ཡིག, Norsk bokmål.', + ); int _selectedIndex = 0; - final List _views = [ - FontsView(), - ControlsView(), + final List _views = [ + const FontsView(), + const ControlsView(), InputsView(), - ColorsView() + const ColorsView() ]; @override @@ -48,16 +49,22 @@ class _HomePageState extends State { child: Padding( padding: const EdgeInsets.all(8.0), child: TextButton( - style: TextButton.styleFrom( - padding: const EdgeInsets.all(0), - shape: const CircleBorder()), - onPressed: () => AppTheme.apply(context, - themeMode: theme.themeMode == ThemeMode.light - ? ThemeMode.dark - : ThemeMode.light), - child: Icon(theme.themeMode == ThemeMode.light + style: TextButton.styleFrom( + padding: const EdgeInsets.all(0), + shape: const CircleBorder(), + ), + onPressed: () => AppTheme.apply( + context, + themeMode: theme.themeMode == ThemeMode.light + ? ThemeMode.dark + : ThemeMode.light, + ), + child: Icon( + theme.themeMode == ThemeMode.light ? Icons.dark_mode - : Icons.light_mode)), + : Icons.light_mode, + ), + ), ), ), actions: [ @@ -85,8 +92,11 @@ class _HomePageState extends State { for (final variant in YaruVariant.values.take(10)) // skip flavors PopupMenuItem( - onTap: () => AppTheme.apply(context, - variant: variant, highContrast: false), + onTap: () => AppTheme.apply( + context, + variant: variant, + highContrast: false, + ), child: ColorDisk( color: variant.color, selected: variant == theme.variant && @@ -110,30 +120,34 @@ class _HomePageState extends State { ), bottomNavigationBar: BottomNavigationBar( landscapeLayout: BottomNavigationBarLandscapeLayout.spread, - items: [ + items: const [ BottomNavigationBarItem( - icon: Icon(Icons.font_download_outlined), - activeIcon: Icon(Icons.font_download), - label: 'Fonts'), + icon: Icon(Icons.font_download_outlined), + activeIcon: Icon(Icons.font_download), + label: 'Fonts', + ), BottomNavigationBarItem( - icon: Icon(Icons.radio_button_checked_outlined), - activeIcon: Icon(Icons.radio_button_checked), - label: 'Controls'), + icon: Icon(Icons.radio_button_checked_outlined), + activeIcon: Icon(Icons.radio_button_checked), + label: 'Controls', + ), BottomNavigationBarItem( - icon: Icon(Icons.text_fields), - activeIcon: Icon(Icons.text_fields_outlined), - label: 'Text Fields'), + icon: Icon(Icons.text_fields), + activeIcon: Icon(Icons.text_fields_outlined), + label: 'Text Fields', + ), BottomNavigationBarItem( - icon: Icon(Icons.color_lens_outlined), - activeIcon: Icon(Icons.color_lens), - label: 'Palette') + icon: Icon(Icons.color_lens_outlined), + activeIcon: Icon(Icons.color_lens), + label: 'Palette', + ) ], currentIndex: _selectedIndex, onTap: (index) => setState(() => _selectedIndex = index), ), floatingActionButton: FloatingActionButton( onPressed: () => {incrementCounter()}, - child: Icon(Icons.plus_one), + child: const Icon(Icons.plus_one), ), floatingActionButtonLocation: FloatingActionButtonLocation.miniCenterDocked, diff --git a/example/lib/view/inputs_view.dart b/example/lib/view/inputs_view.dart index e74167552..119a6a9f3 100644 --- a/example/lib/view/inputs_view.dart +++ b/example/lib/view/inputs_view.dart @@ -2,8 +2,11 @@ import 'package:flutter/material.dart'; class InputsView extends StatelessWidget { final textController = TextEditingController( - text: - 'My code fails, I do not know why.\nMy code works, I do not know why.\nText in other scripts: Tamaziɣt Taqbaylit, 中文(简体), Čeština, Беларуская, Ελληνικά, עברית, Русский, བོད་ཡིག, Norsk bokmål.'); + text: + 'My code fails, I do not know why.\nMy code works, I do not know why.\nText in other scripts: Tamaziɣt Taqbaylit, 中文(简体), Čeština, Беларуская, Ελληνικά, עברית, Русский, བོད་ཡིག, Norsk bokmål.', + ); + + InputsView({super.key}); @override Widget build(BuildContext context) { return Padding( @@ -11,27 +14,28 @@ class InputsView extends StatelessWidget { child: ListView( children: [ const SizedBox(height: 15), - TextField( + const TextField( autofocus: true, decoration: InputDecoration( - hintText: 'Awesome Textfield', - labelText: 'All TextFields have a border in Yaru'), + hintText: 'Awesome Textfield', + labelText: 'All TextFields have a border in Yaru', + ), ), const SizedBox(height: 15), - TextField( + const TextField( decoration: InputDecoration( labelText: 'Username', ), ), const SizedBox(height: 15), - TextField( + const TextField( obscureText: true, decoration: InputDecoration( labelText: 'Password', ), ), const SizedBox(height: 15), - TextField( + const TextField( decoration: InputDecoration( errorText: "You're doing it wrong", ), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b3d32f62e..4486510cc 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,10 +1,10 @@ name: yaru_example description: Demonstrates Yaru theming -publish_to: 'none' +publish_to: "none" version: 1.0.0 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.17.0 <3.0.0" dependencies: flutter: @@ -12,8 +12,10 @@ dependencies: handy_window: ^0.1.2 yaru: path: ../ + yaru_colors: ^0.1.0 dev_dependencies: + flutter_lints: ^2.0.1 flutter_test: sdk: flutter diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 45d52b593..fbfafed35 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -13,7 +13,7 @@ import 'package:yaru_example/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); diff --git a/lib/src/themes/common_themes.dart b/lib/src/themes/common_themes.dart index c6c1418e5..c0ab14131 100644 --- a/lib/src/themes/common_themes.dart +++ b/lib/src/themes/common_themes.dart @@ -67,24 +67,26 @@ final _buttonThemeData = ButtonThemeData( ); final _outlinedButtonThemeData = OutlinedButtonThemeData( - style: OutlinedButton.styleFrom( - side: const BorderSide(color: Colors.black38, width: 0.3), - visualDensity: _commonButtonStyle.visualDensity, - primary: YaruColors.textGrey, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(kButtonRadius), + style: OutlinedButton.styleFrom( + side: const BorderSide(color: Colors.black38, width: 0.3), + visualDensity: _commonButtonStyle.visualDensity, + primary: YaruColors.textGrey, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(kButtonRadius), + ), ), -)); +); final _darkOutlinedButtonThemeData = OutlinedButtonThemeData( - style: OutlinedButton.styleFrom( - side: const BorderSide(color: Colors.white38, width: 0.3), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(kButtonRadius), + style: OutlinedButton.styleFrom( + side: const BorderSide(color: Colors.white38, width: 0.3), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(kButtonRadius), + ), + visualDensity: _commonButtonStyle.visualDensity, + primary: Colors.white, ), - visualDensity: _commonButtonStyle.visualDensity, - primary: Colors.white, -)); +); final _textButtonThemeData = TextButtonThemeData( style: TextButton.styleFrom( @@ -97,47 +99,58 @@ final _textButtonThemeData = TextButtonThemeData( ElevatedButtonThemeData _getElevatedButtonThemeData(Color color) { return ElevatedButtonThemeData( - style: ElevatedButton.styleFrom( - primary: color, - onPrimary: ThemeData.estimateBrightnessForColor(color) == Brightness.light - ? Colors.black - : Colors.white, - visualDensity: _commonButtonStyle.visualDensity, - elevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(kButtonRadius), + style: ElevatedButton.styleFrom( + primary: color, + onPrimary: ThemeData.estimateBrightnessForColor(color) == Brightness.light + ? Colors.black + : Colors.white, + visualDensity: _commonButtonStyle.visualDensity, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(kButtonRadius), + ), ), - )); + ); } const _toggleButtonsTheme = ToggleButtonsThemeData( - borderRadius: BorderRadius.all(Radius.circular(kButtonRadius))); + borderRadius: BorderRadius.all(Radius.circular(kButtonRadius)), +); // Dialogs final _dialogThemeDark = DialogTheme( - backgroundColor: YaruColors.coolGrey, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(kWindowRadius), - side: BorderSide(color: Colors.white.withOpacity(0.2)))); + backgroundColor: YaruColors.coolGrey, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(kWindowRadius), + side: BorderSide(color: Colors.white.withOpacity(0.2)), + ), +); final _dialogThemeLight = DialogTheme( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(kWindowRadius), -)); + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(kWindowRadius), + ), +); // Switches SwitchThemeData _getSwitchThemeData(Color primaryColor, Brightness brightness) { return SwitchThemeData( - thumbColor: MaterialStateProperty.resolveWith( - (states) => _getSwitchThumbColor(states, primaryColor, brightness)), - trackColor: MaterialStateProperty.resolveWith( - (states) => _getSwitchTrackColor(states, primaryColor, brightness))); + thumbColor: MaterialStateProperty.resolveWith( + (states) => _getSwitchThumbColor(states, primaryColor, brightness), + ), + trackColor: MaterialStateProperty.resolveWith( + (states) => _getSwitchTrackColor(states, primaryColor, brightness), + ), + ); } Color _getSwitchThumbColor( - Set states, Color selectedColor, Brightness brightness) { + Set states, + Color selectedColor, + Brightness brightness, +) { if (states.contains(MaterialState.disabled)) { return brightness == Brightness.dark ? kDisabledGreyDark @@ -152,7 +165,10 @@ Color _getSwitchThumbColor( } Color _getSwitchTrackColor( - Set states, Color selectedColor, Brightness brightness) { + Set states, + Color selectedColor, + Brightness brightness, +) { if (states.contains(MaterialState.disabled)) { return brightness == Brightness.dark ? kDisabledGreyDark.withAlpha(120) @@ -173,7 +189,10 @@ Color _getSwitchTrackColor( // Checks & Radios Color _getCheckFillColor( - Set states, Color selectedColor, Brightness brightness) { + Set states, + Color selectedColor, + Brightness brightness, +) { if (!states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.selected)) { return selectedColor; @@ -197,22 +216,28 @@ Color _getCheckColor(Set states, Color color) { } CheckboxThemeData _getCheckBoxThemeData( - Color primaryColor, Brightness brightness) { + Color primaryColor, + Brightness brightness, +) { return CheckboxThemeData( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(kCheckRadius), ), fillColor: MaterialStateProperty.resolveWith( - (states) => _getCheckFillColor(states, primaryColor, brightness)), + (states) => _getCheckFillColor(states, primaryColor, brightness), + ), checkColor: MaterialStateProperty.resolveWith( - (states) => _getCheckColor(states, primaryColor)), + (states) => _getCheckColor(states, primaryColor), + ), ); } RadioThemeData _getRadioThemeData(Color primaryColor, Brightness brightness) { return RadioThemeData( - fillColor: MaterialStateProperty.resolveWith( - (states) => _getCheckFillColor(states, primaryColor, brightness))); + fillColor: MaterialStateProperty.resolveWith( + (states) => _getCheckFillColor(states, primaryColor, brightness), + ), + ); } const _pageTransitionTheme = PageTransitionsTheme( diff --git a/lib/src/themes/kubuntu.dart b/lib/src/themes/kubuntu.dart index 821ee25ab..546d12a52 100644 --- a/lib/src/themes/kubuntu.dart +++ b/lib/src/themes/kubuntu.dart @@ -15,7 +15,9 @@ final _lightColorScheme = ColorScheme.fromSwatch( ); final yaruKubuntuLight = createYaruLightTheme( - colorScheme: _lightColorScheme, primaryColor: _primaryColor); + colorScheme: _lightColorScheme, + primaryColor: _primaryColor, +); final _darkColorScheme = ColorScheme.fromSwatch( primarySwatch: _primaryColor, @@ -28,4 +30,6 @@ final _darkColorScheme = ColorScheme.fromSwatch( ); final yaruKubuntuDark = createYaruDarkTheme( - colorScheme: _darkColorScheme, primaryColor: _primaryColor); + colorScheme: _darkColorScheme, + primaryColor: _primaryColor, +); diff --git a/lib/src/themes/lubuntu.dart b/lib/src/themes/lubuntu.dart index d2f9ee5be..1e47ae5a7 100644 --- a/lib/src/themes/lubuntu.dart +++ b/lib/src/themes/lubuntu.dart @@ -15,7 +15,9 @@ final _lightColorScheme = ColorScheme.fromSwatch( ); final yaruLubuntuLight = createYaruLightTheme( - colorScheme: _lightColorScheme, primaryColor: _primaryColor); + colorScheme: _lightColorScheme, + primaryColor: _primaryColor, +); final _darkColorScheme = ColorScheme.fromSwatch( primarySwatch: _primaryColor, @@ -28,4 +30,6 @@ final _darkColorScheme = ColorScheme.fromSwatch( ); final yaruLubuntuDark = createYaruDarkTheme( - colorScheme: _darkColorScheme, primaryColor: _primaryColor); + colorScheme: _darkColorScheme, + primaryColor: _primaryColor, +); diff --git a/lib/src/themes/ubuntu_budgie.dart b/lib/src/themes/ubuntu_budgie.dart index b05c9109b..0b3e9b31b 100644 --- a/lib/src/themes/ubuntu_budgie.dart +++ b/lib/src/themes/ubuntu_budgie.dart @@ -15,7 +15,9 @@ final _lightColorScheme = ColorScheme.fromSwatch( ); final yaruUbuntuBudgieLight = createYaruLightTheme( - colorScheme: _lightColorScheme, primaryColor: _primaryColor); + colorScheme: _lightColorScheme, + primaryColor: _primaryColor, +); final _darkColorScheme = ColorScheme.fromSwatch( primarySwatch: _primaryColor, @@ -28,4 +30,6 @@ final _darkColorScheme = ColorScheme.fromSwatch( ); final yaruUbuntuBudgieDark = createYaruDarkTheme( - colorScheme: _darkColorScheme, primaryColor: _primaryColor); + colorScheme: _darkColorScheme, + primaryColor: _primaryColor, +); diff --git a/lib/src/themes/ubuntu_mate.dart b/lib/src/themes/ubuntu_mate.dart index 7196bd019..7c7b4f7e7 100644 --- a/lib/src/themes/ubuntu_mate.dart +++ b/lib/src/themes/ubuntu_mate.dart @@ -18,7 +18,9 @@ final _lightColorScheme = ColorScheme.fromSwatch( final yaruMateLight = yaruUbuntuMateLight; final yaruUbuntuMateLight = createYaruLightTheme( - colorScheme: _lightColorScheme, primaryColor: _primaryColor); + colorScheme: _lightColorScheme, + primaryColor: _primaryColor, +); final _darkColorScheme = ColorScheme.fromSwatch( primarySwatch: _primaryColor, @@ -34,4 +36,6 @@ final _darkColorScheme = ColorScheme.fromSwatch( final yaruMateDark = yaruUbuntuMateDark; final yaruUbuntuMateDark = createYaruDarkTheme( - colorScheme: _darkColorScheme, primaryColor: _primaryColor); + colorScheme: _darkColorScheme, + primaryColor: _primaryColor, +); diff --git a/lib/src/themes/ubuntu_studio.dart b/lib/src/themes/ubuntu_studio.dart index c997d7ed7..498384243 100644 --- a/lib/src/themes/ubuntu_studio.dart +++ b/lib/src/themes/ubuntu_studio.dart @@ -15,7 +15,9 @@ final _lightColorScheme = ColorScheme.fromSwatch( ); final yaruUbuntuStudioLight = createYaruLightTheme( - colorScheme: _lightColorScheme, primaryColor: _primaryColor); + colorScheme: _lightColorScheme, + primaryColor: _primaryColor, +); final _darkColorScheme = ColorScheme.fromSwatch( primarySwatch: _primaryColor, @@ -28,4 +30,6 @@ final _darkColorScheme = ColorScheme.fromSwatch( ); final yaruUbuntuStudioDark = createYaruDarkTheme( - colorScheme: _darkColorScheme, primaryColor: _primaryColor); + colorScheme: _darkColorScheme, + primaryColor: _primaryColor, +); diff --git a/lib/src/themes/xubuntu.dart b/lib/src/themes/xubuntu.dart index 0f8a30958..a5b94f389 100644 --- a/lib/src/themes/xubuntu.dart +++ b/lib/src/themes/xubuntu.dart @@ -15,7 +15,9 @@ final _lightColorScheme = ColorScheme.fromSwatch( ); final yaruXubuntuLight = createYaruLightTheme( - colorScheme: _lightColorScheme, primaryColor: _primaryColor); + colorScheme: _lightColorScheme, + primaryColor: _primaryColor, +); final _darkColorScheme = ColorScheme.fromSwatch( primarySwatch: _primaryColor, @@ -28,4 +30,6 @@ final _darkColorScheme = ColorScheme.fromSwatch( ); final yaruXubuntuDark = createYaruDarkTheme( - colorScheme: _darkColorScheme, primaryColor: _primaryColor); + colorScheme: _darkColorScheme, + primaryColor: _primaryColor, +); diff --git a/lib/src/themes/yaru.dart b/lib/src/themes/yaru.dart index c14c26b77..dacec2005 100644 --- a/lib/src/themes/yaru.dart +++ b/lib/src/themes/yaru.dart @@ -15,9 +15,10 @@ final _lightColorScheme = ColorScheme.fromSwatch( ); final yaruLight = createYaruLightTheme( - colorScheme: _lightColorScheme, - primaryColor: _primaryColor, - elevatedButtonColor: YaruColors.success); + colorScheme: _lightColorScheme, + primaryColor: _primaryColor, + elevatedButtonColor: YaruColors.success, +); final _darkColorScheme = ColorScheme.fromSwatch( primarySwatch: _primaryColor, @@ -30,9 +31,10 @@ final _darkColorScheme = ColorScheme.fromSwatch( ); final yaruDark = createYaruDarkTheme( - colorScheme: _darkColorScheme, - primaryColor: _primaryColor, - elevatedButtonColor: YaruColors.success); + colorScheme: _darkColorScheme, + primaryColor: _primaryColor, + elevatedButtonColor: YaruColors.success, +); final yaruSageLight = createYaruLightTheme( colorScheme: ColorScheme.fromSwatch( diff --git a/lib/src/widgets/inherited_theme.dart b/lib/src/widgets/inherited_theme.dart index 396678f96..fa201f6c9 100644 --- a/lib/src/widgets/inherited_theme.dart +++ b/lib/src/widgets/inherited_theme.dart @@ -85,8 +85,10 @@ class YaruTheme extends StatefulWidget { this.data = const YaruThemeData(), @visibleForTesting Platform? platform, @visibleForTesting GSettings? settings, - }) : assert(builder != null || child != null, - 'Either builder or child must be provided'), + }) : assert( + builder != null || child != null, + 'Either builder or child must be provided', + ), _platform = platform ?? const LocalPlatform(), _settings = settings; diff --git a/test/widget_test.dart b/test/widget_test.dart index 625a6baf7..3af2fd246 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -173,18 +173,20 @@ extension ThemeTester on WidgetTester { highContrast: highContrast, themeMode: themeMode, ); - await pumpWidget(MaterialApp( - key: ValueKey(data), - home: YaruTheme( - child: Container(), - data: data, - platform: FakePlatform( - operatingSystem: Platform.linux, - environment: {'XDG_CURRENT_DESKTOP': desktop}, + await pumpWidget( + MaterialApp( + key: ValueKey(data), + home: YaruTheme( + child: Container(), + data: data, + platform: FakePlatform( + operatingSystem: Platform.linux, + environment: {'XDG_CURRENT_DESKTOP': desktop}, + ), + settings: settings, ), - settings: settings, ), - )); + ); return pump(); } }