Skip to content

Commit

Permalink
Merge pull request #30 from Hixie/analysis
Browse files Browse the repository at this point in the history
Fix newer analysis errors.
  • Loading branch information
marcglasberg authored Dec 6, 2023
2 parents 561a43e + 2a7e367 commit added2d
Show file tree
Hide file tree
Showing 31 changed files with 156 additions and 104 deletions.
11 changes: 0 additions & 11 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ linter:
# http://dart-lang.github.io/linter/lints/always_declare_return_types.html
# - always_put_required_named_parameters_first

# All non nullable named parameters should be and annotated with @required.
# This allows API consumers to get warnings via lint rather than a crash a runtime.
# Might become obsolete with Non-Nullable types
# http://dart-lang.github.io/linter/lints/always_require_non_null_named_parameters.html
- always_require_non_null_named_parameters

# Since dart 2.0 dart is a sound language, specifying types is not required anymore.
# `var foo = 10;` is enough information for the compiler to make foo a int.
# Violates Effective Dart "AVOID type annotating initialized local variables".
Expand Down Expand Up @@ -173,11 +167,6 @@ linter:
# https://dart-lang.github.io/linter/lints/avoid_returning_null.html
# - avoid_returning_null

# Don't use `Future?`, therefore never return null instead of a Future.
# Will become obsolete one Non-Nullable types land
# https://dart-lang.github.io/linter/lints/avoid_returning_null_for_future.html
- avoid_returning_null_for_future

# Use empty returns, don't show off with you knowledge about dart internals.
# https://dart-lang.github.io/linter/lints/avoid_returning_null_for_void.html
- avoid_returning_null_for_void
Expand Down
2 changes: 1 addition & 1 deletion example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
avoid_print: false
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
Expand Down
4 changes: 3 additions & 1 deletion example/lib/main_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Demo()));
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
const Demo({ super.key });

@override
Widget build(BuildContext context) {
//
Expand Down
38 changes: 20 additions & 18 deletions example/lib/main_button_and_circle_button.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Demo()));
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
const Demo({ super.key });

@override
Widget build(BuildContext context) {
//
Expand All @@ -13,11 +15,11 @@ class Demo extends StatelessWidget {
child: Center(
child: Column(
children: [
Box(height: 20),
const Box(height: 20),
_button(),
Box(height: 20),
const Box(height: 20),
_circleButton(),
Box(height: 20),
const Box(height: 20),
],
),
),
Expand All @@ -31,17 +33,17 @@ class Demo extends StatelessWidget {
color: Colors.indigo,
child: Column(
children: [
Text('Button',
const Text('Button',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white)),
Box(height: 20),
const Box(height: 20),
Row(
children: [
Expanded(
child: Center(
child: Button(
builder: ({required bool isPressed}) {
return Box(
padding: Pad(all: 8.0),
padding: const Pad(all: 8.0),
color: isPressed ? Colors.blue : Colors.transparent,
child: Text(
'Click Me',
Expand All @@ -50,7 +52,7 @@ class Demo extends StatelessWidget {
),
);
},
minVisualTapDuration: Duration(milliseconds: 500),
minVisualTapDuration: const Duration(milliseconds: 500),
clickAreaMargin: const Pad(horizontal: 10.0, vertical: 45),
onTap: () {},
),
Expand All @@ -61,7 +63,7 @@ class Demo extends StatelessWidget {
child: Button(
builder: ({required bool isPressed}) {
return Box(
padding: Pad(all: 8.0),
padding: const Pad(all: 8.0),
color: isPressed ? Colors.blue : Colors.transparent,
child: Text(
'Click Me',
Expand All @@ -70,7 +72,7 @@ class Demo extends StatelessWidget {
),
);
},
minVisualTapDuration: Duration(milliseconds: 500),
minVisualTapDuration: const Duration(milliseconds: 500),
clickAreaMargin: const Pad(horizontal: 10.0, vertical: 45),
debugShowClickableArea: true,
onTap: () {},
Expand All @@ -79,8 +81,8 @@ class Demo extends StatelessWidget {
),
],
),
Box(height: 20),
Text(
const Box(height: 20),
const Text(
'Button(\n'
' builder: ({required bool isPressed}) => ...\n'
' minVisualTapDuration: Duration(milliseconds: 500),\n'
Expand All @@ -99,15 +101,15 @@ class Demo extends StatelessWidget {
color: Colors.indigo,
child: Column(
children: [
Text('CircleButton',
const Text('CircleButton',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white)),
Box(height: 20),
const Box(height: 20),
Row(
children: [
Expanded(
child: Center(
child: CircleButton(
icon: Icon(Icons.shopping_cart, color: Colors.white),
icon: const Icon(Icons.shopping_cart, color: Colors.white),
clickAreaMargin: const Pad(left: 30, right: 50, vertical: 20),
backgroundColor: Colors.white30,
tapColor: Colors.black,
Expand All @@ -120,7 +122,7 @@ class Demo extends StatelessWidget {
Expanded(
child: Center(
child: CircleButton(
icon: Icon(Icons.shopping_cart, color: Colors.white),
icon: const Icon(Icons.shopping_cart, color: Colors.white),
clickAreaMargin: const Pad(left: 50, right: 30, vertical: 20),
debugShowClickableArea: true,
backgroundColor: Colors.white30,
Expand All @@ -133,8 +135,8 @@ class Demo extends StatelessWidget {
),
],
),
Box(height: 20),
Text(
const Box(height: 20),
const Text(
'CircleButton(\n'
' icon: Icon(Icons.shopping_cart, color: Colors.white),\n'
' backgroundColor: Colors.white30,\n'
Expand Down
4 changes: 3 additions & 1 deletion example/lib/main_button_bar_super.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Demo()));
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
const Demo({ super.key });

@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('ButtonBarSuper Example')),
Expand Down
14 changes: 8 additions & 6 deletions example/lib/main_capture_gestures.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Demo()));
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
const Demo({ super.key });

@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('CaptureGestures Example')),
body: ListView(
physics: BouncingScrollPhysics(),
physics: const BouncingScrollPhysics(),
children: [
const Box(height: 30),
_greenArea(),
Expand Down Expand Up @@ -36,10 +38,10 @@ class Demo extends StatelessWidget {
children: [
ElevatedButton(
onPressed: () {},
child: Text('Button'),
child: const Text('Button'),
),
const Box(height: 20),
Text('CaptureGestures.only()\n\n'
const Text('CaptureGestures.only()\n\n'
'This green area can be used to scroll.\n'
'The Button (child) feels taps.\n'
'The green area (parent) feels taps.'),
Expand Down Expand Up @@ -68,11 +70,11 @@ class Demo extends StatelessWidget {
Center(
child: ElevatedButton(
onPressed: () {},
child: Text('Button'),
child: const Text('Button'),
),
),
const Box(height: 20),
Text('CaptureGestures.scroll()\n\n'
const Text('CaptureGestures.scroll()\n\n'
'This yellow area CANNOT be used to scroll.\n'
'The Button (child) feels taps.\n'
'The yellow area (parent) feels taps.'),
Expand Down
12 changes: 6 additions & 6 deletions example/lib/main_column_removing_zero_height.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
const Demo({Key? key}) : super(key: key);
const Demo({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('ColumnSuper Remove Children')),
body: Column(
body: const Column(
children: [
const Padding(
Padding(
padding: Pad(all: 20),
child:
Text("Click the colored boxes to turn their height to zero (they keep their width)."
Expand All @@ -25,7 +25,7 @@ class Demo extends StatelessWidget {
child: Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: const [
children: [
ColoredColumn(removeChildrenWithNoHeight: false),
Box(width: 50),
ColoredColumn(removeChildrenWithNoHeight: true),
Expand All @@ -48,10 +48,10 @@ class Demo extends StatelessWidget {
class ColoredColumn extends StatefulWidget {
final bool removeChildrenWithNoHeight;

const ColoredColumn({required this.removeChildrenWithNoHeight});
const ColoredColumn({super.key, required this.removeChildrenWithNoHeight});

@override
_ColoredColumnState createState() => _ColoredColumnState();
State<ColoredColumn> createState() => _ColoredColumnState();
}

class _ColoredColumnState extends State<ColoredColumn> {
Expand Down
4 changes: 3 additions & 1 deletion example/lib/main_column_super.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Demo()));
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
const Demo({super.key});

@override
Widget build(BuildContext context) {
//
Expand Down
22 changes: 14 additions & 8 deletions example/lib/main_column_super_playground.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Demo()));
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatefulWidget {
const Demo({super.key});

@override
_DemoState createState() => _DemoState();
State<Demo> createState() => _DemoState();
}

class _DemoState extends State<Demo> {
Expand Down Expand Up @@ -137,19 +139,23 @@ class _DemoState extends State<Demo> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
button("Parent Width = $parentWidth", () {
if (parentWidth == null)
if (parentWidth == null) {
parentWidth = 70.0;
else if (parentWidth == 70.0)
} else if (parentWidth == 70.0) {
parentWidth = double.infinity;
else if (parentWidth == double.infinity) parentWidth = null;
} else if (parentWidth == double.infinity) {
parentWidth = null;
}
}),
const Box(width: 10.0),
button("Alignment = $alignment", () {
if (alignment == Alignment.center)
if (alignment == Alignment.center) {
alignment = Alignment.topLeft;
else if (alignment == Alignment.topLeft)
} else if (alignment == Alignment.topLeft) {
alignment = Alignment.topRight;
else if (alignment == Alignment.topRight) alignment = Alignment.center;
} else if (alignment == Alignment.topRight) {
alignment = Alignment.center;
}
}),
],
),
Expand Down
4 changes: 3 additions & 1 deletion example/lib/main_delayed.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Demo()));
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
const Demo({super.key});

@override
Widget build(BuildContext context) {
//
Expand Down
4 changes: 3 additions & 1 deletion example/lib/main_fit_horizontally.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Demo()));
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
const Demo({super.key});

@override
Widget build(BuildContext context) {
//
Expand Down
4 changes: 3 additions & 1 deletion example/lib/main_fit_horizontally_baseline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Demo()));
void main() => runApp(const MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
const Demo({super.key});

@override
Widget build(BuildContext context) {
//
Expand Down
6 changes: 4 additions & 2 deletions example/lib/main_global_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) => const MaterialApp(
home: MyHomePage(),
);
}

class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
const MyHomePage({super.key});

@override
Widget build(BuildContext context) {
Expand Down
Loading

0 comments on commit added2d

Please sign in to comment.