Skip to content

Commit

Permalink
Update lints in the example app
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Sep 15, 2021
1 parent 4aa2a3d commit ed953b5
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 142 deletions.
1 change: 1 addition & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml
68 changes: 40 additions & 28 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart';
import 'package:provider/provider.dart';
import 'package:system_theme/system_theme.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart' as FlutterAcrylic;
import 'package:flutter_acrylic/flutter_acrylic.dart' as flutter_acrylic;
import 'package:url_strategy/url_strategy.dart';

import 'screens/colors.dart';
Expand Down Expand Up @@ -51,20 +51,21 @@ void main() async {
if (!kIsWeb &&
[TargetPlatform.windows, TargetPlatform.linux]
.contains(defaultTargetPlatform)) {
await FlutterAcrylic.Acrylic.initialize();
await flutter_acrylic.Acrylic.initialize();
}

runApp(MyApp());
runApp(const MyApp());

if (isDesktop)
if (isDesktop) {
doWhenWindowReady(() {
final win = appWindow;
win.minSize = Size(410, 540);
win.size = Size(755, 545);
win.minSize = const Size(410, 540);
win.size = const Size(755, 545);
win.alignment = Alignment.center;
win.title = appTitle;
win.show();
});
}
}

class MyApp extends StatelessWidget {
Expand All @@ -81,7 +82,7 @@ class MyApp extends StatelessWidget {
themeMode: appTheme.mode,
debugShowCheckedModeBanner: false,
initialRoute: '/',
routes: {'/': (_) => MyHomePage()},
routes: {'/': (_) => const MyHomePage()},
theme: ThemeData(
accentColor: appTheme.color,
brightness: appTheme.mode == ThemeMode.system
Expand Down Expand Up @@ -131,9 +132,9 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: NavigationAppBar(
// height: !kIsWeb ? appWindow.titleBarHeight : 31.0,
title: () {
if (kIsWeb) return Text(appTitle);
if (kIsWeb) return const Text(appTitle);
return MoveWindow(
child: Align(
child: const Align(
alignment: Alignment.centerLeft,
child: Text(appTitle),
),
Expand All @@ -144,7 +145,7 @@ class _MyHomePageState extends State<MyHomePage> {
: MoveWindow(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [Spacer(), WindowButtons()],
children: const [Spacer(), WindowButtons()],
),
),
),
Expand All @@ -154,7 +155,7 @@ class _MyHomePageState extends State<MyHomePage> {
header: Container(
height: kOneLineTileHeight,
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: FlutterLogo(
child: const FlutterLogo(
style: FlutterLogoStyle.horizontal,
size: 100,
),
Expand Down Expand Up @@ -207,43 +208,53 @@ class _MyHomePageState extends State<MyHomePage> {
// It doesn't look good when resizing from compact to open
// PaneItemHeader(header: Text('User Interaction')),
PaneItem(
icon: Icon(FluentIcons.checkbox_composite),
title: Text('Inputs'),
icon: const Icon(FluentIcons.checkbox_composite),
title: const Text('Inputs'),
),
PaneItem(
icon: const Icon(FluentIcons.text_field),
title: const Text('Forms'),
),
PaneItem(icon: Icon(FluentIcons.text_field), title: Text('Forms')),
PaneItemSeparator(),
PaneItem(icon: Icon(FluentIcons.color), title: Text('Colors')),
PaneItem(
icon: Icon(FluentIcons.plain_text),
title: Text('Typography'),
icon: const Icon(FluentIcons.color),
title: const Text('Colors'),
),
PaneItem(icon: Icon(FluentIcons.cell_phone), title: Text('Mobile')),
PaneItem(
icon: const Icon(FluentIcons.plain_text),
title: const Text('Typography'),
),
PaneItem(
icon: const Icon(FluentIcons.cell_phone),
title: const Text('Mobile')),
PaneItem(
icon: Icon(
appTheme.displayMode == PaneDisplayMode.top
? FluentIcons.more
: FluentIcons.more_vertical,
),
title: Text('Others'),
title: const Text('Others'),
),
],
autoSuggestBox: AutoSuggestBox<String>(
controller: TextEditingController(),
items: ['Item 1', 'Item 2', 'Item 3', 'Item 4'],
items: const ['Item 1', 'Item 2', 'Item 3', 'Item 4'],
),
autoSuggestBoxReplacement: Icon(FluentIcons.search),
autoSuggestBoxReplacement: const Icon(FluentIcons.search),
footerItems: [
PaneItemSeparator(),
PaneItem(icon: Icon(FluentIcons.settings), title: Text('Settings')),
PaneItem(
icon: const Icon(FluentIcons.settings),
title: const Text('Settings')),
],
),
content: NavigationBody(index: index, children: [
InputsPage(),
Forms(),
const InputsPage(),
const Forms(),
ColorsPage(controller: colorsController),
TypographyPage(),
Mobile(),
Others(),
const TypographyPage(),
const Mobile(),
const Others(),
Settings(controller: settingsController),
]),
);
Expand Down Expand Up @@ -284,8 +295,9 @@ class WindowButtons extends StatelessWidget {
child: WindowButton(
colors: buttonColors,
iconBuilder: (context) {
if (appWindow.isMaximized)
if (appWindow.isMaximized) {
return RestoreIcon(color: context.iconColor);
}
return MaximizeIcon(color: context.iconColor);
},
onPressed: appWindow.maximizeOrRestore,
Expand Down
22 changes: 11 additions & 11 deletions example/lib/screens/colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ class ColorsPage extends StatelessWidget {

Widget buildColorBlock(String name, Color color) {
return Container(
constraints: BoxConstraints(
constraints: const BoxConstraints(
minHeight: 65,
minWidth: 65,
),
padding: EdgeInsets.all(2.0),
padding: const EdgeInsets.all(2.0),
color: color,
child: Column(mainAxisAlignment: MainAxisAlignment.end, children: [
Text(name, style: TextStyle(color: color.basedOnLuminance())),
Expand All @@ -21,14 +21,14 @@ class ColorsPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
const Divider divider = const Divider(
style: const DividerThemeData(
verticalMargin: const EdgeInsets.all(10),
horizontalMargin: const EdgeInsets.all(10),
const Divider divider = Divider(
style: DividerThemeData(
verticalMargin: EdgeInsets.all(10),
horizontalMargin: EdgeInsets.all(10),
),
);
return ScaffoldPage(
header: PageHeader(title: Text('Colors Showcase')),
header: const PageHeader(title: Text('Colors Showcase')),
content: ListView(
padding: EdgeInsets.only(
bottom: kPageDefaultVerticalPadding,
Expand Down Expand Up @@ -73,7 +73,7 @@ class ColorsPage extends StatelessWidget {
buildColorBlock('Black', Colors.black),
buildColorBlock('White', Colors.white),
]),
SizedBox(height: 10),
const SizedBox(height: 10),
Wrap(
children: List.generate(22, (index) {
return buildColorBlock(
Expand All @@ -82,7 +82,7 @@ class ColorsPage extends StatelessWidget {
);
}),
),
SizedBox(height: 10),
const SizedBox(height: 10),
Wrap(
children: accent,
runSpacing: 10,
Expand All @@ -97,7 +97,7 @@ class ColorsPage extends StatelessWidget {

List<Widget> get accent {
List<Widget> children = [];
Colors.accentColors.forEach((AccentColor accent) {
for (final accent in Colors.accentColors) {
children.add(
Wrap(
// mainAxisSize: MainAxisSize.min,
Expand All @@ -108,7 +108,7 @@ class ColorsPage extends StatelessWidget {
}),
),
);
});
}
return children;
}
}
39 changes: 21 additions & 18 deletions example/lib/screens/forms.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

import 'package:fluent_ui/fluent_ui.dart';

class Forms extends StatefulWidget {
Expand All @@ -21,34 +23,34 @@ class _FormsState extends State<Forms> {
@override
Widget build(BuildContext context) {
return ScaffoldPage(
header: PageHeader(title: Text('Forms showcase')),
header: const PageHeader(title: Text('Forms showcase')),
content: ListView(
padding: EdgeInsets.only(
bottom: kPageDefaultVerticalPadding,
left: PageHeader.horizontalPadding(context),
right: PageHeader.horizontalPadding(context),
),
children: [
TextBox(
const TextBox(
header: 'Email',
placeholder: 'Type your email here :)',
),
SizedBox(height: 20),
const SizedBox(height: 20),
Row(children: [
Expanded(
const Expanded(
child: TextBox(
readOnly: true,
placeholder: 'Read only text box',
),
),
SizedBox(width: 10),
Expanded(
const SizedBox(width: 10),
const Expanded(
child: TextBox(
enabled: false,
placeholder: 'Disabled text box',
),
),
SizedBox(width: 10),
const SizedBox(width: 10),
Expanded(
child: AutoSuggestBox<String>(
controller: autoSuggestBox,
Expand All @@ -63,7 +65,7 @@ class _FormsState extends State<Forms> {
focusNode: focusNode,
suffixMode: OverlayVisibilityMode.editing,
suffix: IconButton(
icon: Icon(FluentIcons.close),
icon: const Icon(FluentIcons.close),
onPressed: () {
controller.clear();
focusNode.unfocus();
Expand All @@ -77,21 +79,21 @@ class _FormsState extends State<Forms> {
),
),
]),
SizedBox(height: 20),
const SizedBox(height: 20),
TextBox(
maxLines: null,
controller: _clearController,
suffixMode: OverlayVisibilityMode.always,
minHeight: 100,
suffix: IconButton(
icon: Icon(FluentIcons.close),
icon: const Icon(FluentIcons.close),
onPressed: () {
_clearController.clear();
},
),
placeholder: 'Text box with clear button',
),
SizedBox(height: 20),
const SizedBox(height: 20),
TextBox(
header: 'Password',
placeholder: 'Type your placeholder here',
Expand All @@ -107,12 +109,12 @@ class _FormsState extends State<Forms> {
outsideSuffix: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Button(
child: Text('Done'),
child: const Text('Done'),
onPressed: () {},
),
),
),
SizedBox(height: 20),
const SizedBox(height: 20),
Mica(
child: Padding(
padding: const EdgeInsets.all(8.0),
Expand All @@ -122,7 +124,7 @@ class _FormsState extends State<Forms> {
child: InfoLabel(
label: 'Colors',
child: Combobox<String>(
placeholder: Text('Choose a color'),
placeholder: const Text('Choose a color'),
isExpanded: true,
items: values
.map((e) => ComboboxItem<String>(
Expand All @@ -133,13 +135,14 @@ class _FormsState extends State<Forms> {
value: comboBoxValue,
onChanged: (value) {
print(value);
if (value != null)
if (value != null) {
setState(() => comboBoxValue = value);
}
},
),
),
),
SizedBox(width: 12),
const SizedBox(width: 12),
SizedBox(
width: 295,
child: DatePicker(
Expand All @@ -149,7 +152,7 @@ class _FormsState extends State<Forms> {
onChanged: (v) => setState(() => date = v),
),
),
SizedBox(width: 12),
const SizedBox(width: 12),
SizedBox(
width: 240,
child: TimePicker(
Expand All @@ -162,7 +165,7 @@ class _FormsState extends State<Forms> {
]),
),
),
SizedBox(height: 20),
const SizedBox(height: 20),
],
),
);
Expand Down
Loading

0 comments on commit ed953b5

Please sign in to comment.