Skip to content

Commit

Permalink
refactor(widgetbook): ♻️ warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshor committed Feb 1, 2023
1 parent 381ea59 commit 8bf0b12
Show file tree
Hide file tree
Showing 59 changed files with 154 additions and 438 deletions.
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
analyzer:
exclude:
- "bricks"
1 change: 0 additions & 1 deletion examples/custom_theme_example/lib/main.widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class HotReload extends StatelessWidget {
),
),
],
appInfo: AppInfo(name: 'Custom Theme Example'),
directories: [
WidgetbookCategory(
name: 'Default',
Expand Down
1 change: 0 additions & 1 deletion examples/knobs_example/lib/widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class KnobsExample extends StatelessWidget {
],
),
],
appInfo: AppInfo(name: 'Meal App'),
);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ class HotReload extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Widgetbook.material(
appInfo: AppInfo(
name: 'Test App',
),
addons: [
CustomThemeAddon<ThemeData>(
setting: ThemeSetting<ThemeData>.firstAsSelected(
Expand Down Expand Up @@ -120,7 +117,7 @@ class HotReload extends StatelessWidget {
WidgetbookUseCase(
name: 'Test Use Case 4',
builder: (context) =>
const TestWidget(text: 'Test Widget 4'),
const TestWidget(text: 'Test Widget 4'),
),
],
),
Expand All @@ -131,7 +128,7 @@ class HotReload extends StatelessWidget {
WidgetbookUseCase(
name: 'Test Use Case 5',
builder: (context) =>
const TestWidget(text: 'Test Widget 5'),
const TestWidget(text: 'Test Widget 5'),
),
],
),
Expand Down
16 changes: 16 additions & 0 deletions examples/widgetbook_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "8.1.1"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
url: "https://pub.dev"
source: hosted
version: "2.0.1"
flutter_localizations:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -157,6 +165,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.7.0"
lints:
dependency: transitive
description:
name: lints
sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
logging:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions examples/widgetbook_example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
device_frame: ^1.1.0
flutter_lints: ^2.0.1

flutter:
uses-material-design: true
Expand Down
41 changes: 20 additions & 21 deletions examples/widgetbook_example/widgetbook/widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:widgetbook_example/widgets/new_tag.dart';
import 'package:widgetbook_example/widgets/rotated_image.dart';

void main() {
runApp(HotreloadWidgetbook());
runApp(const HotreloadWidgetbook());
}

class HotreloadWidgetbook extends StatelessWidget {
Expand All @@ -24,7 +24,7 @@ class HotreloadWidgetbook extends StatelessWidget {
final devices = [
Apple.iPhone11,
Apple.iPhone12,
Device.special(
const Device.special(
name: 'Test',
resolution: Resolution(
nativeSize: DeviceSize(width: 400, height: 400),
Expand Down Expand Up @@ -59,17 +59,17 @@ class HotreloadWidgetbook extends StatelessWidget {
],
),
localizationSetting: LocalizationSetting(
activeLocale: Locale('en'),
activeLocale: const Locale('en'),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
locales: [
Locale('en'),
Locale('de'),
Locale('fr'),
const Locale('en'),
const Locale('de'),
const Locale('fr'),
],
),
),
Expand All @@ -86,11 +86,11 @@ class HotreloadWidgetbook extends StatelessWidget {
useCases: [
WidgetbookUseCase(
name: 'Short price',
builder: (context) => PriceAttribute(price: 8.5),
builder: (context) => const PriceAttribute(price: 8.5),
),
WidgetbookUseCase(
name: 'Long price',
builder: (context) => PriceAttribute(price: 108.5),
builder: (context) => const PriceAttribute(price: 108.5),
),
],
),
Expand All @@ -99,13 +99,13 @@ class HotreloadWidgetbook extends StatelessWidget {
useCases: [
WidgetbookUseCase(
name: 'Short weight',
builder: (context) => WeightAttribute(
builder: (context) => const WeightAttribute(
weight: 320,
),
),
WidgetbookUseCase(
name: 'Long weight',
builder: (context) => WeightAttribute(
builder: (context) => const WeightAttribute(
weight: 1050,
),
),
Expand All @@ -118,7 +118,7 @@ class HotreloadWidgetbook extends StatelessWidget {
useCases: [
WidgetbookUseCase(
name: 'Shortl list ',
builder: (context) => Ingredients(
builder: (context) => const Ingredients(
ingredients: [
'tomato',
'beef',
Expand All @@ -128,7 +128,7 @@ class HotreloadWidgetbook extends StatelessWidget {
),
WidgetbookUseCase(
name: 'Medium list',
builder: (context) => Ingredients(
builder: (context) => const Ingredients(
ingredients: [
'tomato',
'beef',
Expand All @@ -141,7 +141,7 @@ class HotreloadWidgetbook extends StatelessWidget {
),
WidgetbookUseCase(
name: 'Long list',
builder: (context) => Ingredients(
builder: (context) => const Ingredients(
ingredients: [
'tomato',
'beef',
Expand All @@ -162,7 +162,7 @@ class HotreloadWidgetbook extends StatelessWidget {
useCases: [
WidgetbookUseCase(
name: 'Default',
builder: (context) => NewTag(),
builder: (context) => const NewTag(),
),
],
),
Expand All @@ -171,7 +171,7 @@ class HotreloadWidgetbook extends StatelessWidget {
useCases: [
WidgetbookUseCase(
name: 'Default',
builder: (context) => RotatedImage(
builder: (context) => const RotatedImage(
assetPath: 'assets/burger.jpg',
),
),
Expand Down Expand Up @@ -227,11 +227,11 @@ class HotreloadWidgetbook extends StatelessWidget {
useCases: [
WidgetbookUseCase(
name: 'Short price',
builder: (context) => PriceAttribute(price: 8.5),
builder: (context) => const PriceAttribute(price: 8.5),
),
WidgetbookUseCase(
name: 'Long price',
builder: (context) => PriceAttribute(price: 108.5),
builder: (context) => const PriceAttribute(price: 108.5),
),
],
),
Expand All @@ -240,13 +240,13 @@ class HotreloadWidgetbook extends StatelessWidget {
useCases: [
WidgetbookUseCase(
name: 'Short weight',
builder: (context) => WeightAttribute(
builder: (context) => const WeightAttribute(
weight: 320,
),
),
WidgetbookUseCase(
name: 'Long weight',
builder: (context) => WeightAttribute(
builder: (context) => const WeightAttribute(
weight: 1050,
),
),
Expand All @@ -257,7 +257,7 @@ class HotreloadWidgetbook extends StatelessWidget {
useCases: [
WidgetbookUseCase(
name: 'Multiline Knob',
builder: (context) => MultiLineKnob(),
builder: (context) => const MultiLineKnob(),
),
WidgetbookUseCase(
name: 'Color Knob',
Expand All @@ -276,7 +276,6 @@ class HotreloadWidgetbook extends StatelessWidget {
],
),
],
appInfo: AppInfo(name: 'Meal App'),
);
}

Expand Down
1 change: 0 additions & 1 deletion packages/widgetbook/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class HotreloadWidgetbook extends StatelessWidget {
],
)
],
appInfo: AppInfo(name: 'Example'),
);
}
}
9 changes: 0 additions & 9 deletions packages/widgetbook/lib/src/addons/addon.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
import 'package:flutter/widgets.dart';
import 'package:nested/nested.dart';
import 'package:widgetbook/src/addons/models/panel_size.dart';

class WidgetbookAddOn {
const WidgetbookAddOn({
required this.icon,
required this.name,
// TODO This can be optional/nullable
required this.wrapperBuilder,
required this.builder,
required this.providerBuilder,
required this.getQueryParameter,
this.panelSize = PanelSize.small,
});

// TODO if we make this a builder, we can access buildcontext
final Widget icon;

final String name;

final PanelSize panelSize;

final Widget Function(
BuildContext context,
Map<String, dynamic> routerData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:nested/nested.dart';
import 'package:widgetbook/src/addons/addon.dart';

// TODO do we still need this?
class AddonInjectorWidget extends StatelessWidget {
const AddonInjectorWidget({
super.key,
Expand Down
Loading

0 comments on commit 8bf0b12

Please sign in to comment.