Skip to content

Commit

Permalink
migrate to null safety
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Dormevil committed Feb 8, 2021
1 parent d1cb3df commit a7a27b8
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 174 deletions.
30 changes: 15 additions & 15 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

Expand Down Expand Up @@ -187,10 +187,10 @@ class _MyHomePageState extends State<MyHomePage> {

class AvatarOverview extends StatelessWidget {
AvatarOverview({
Key key,
@required int remaining,
@required int position,
@required int counter,
Key? key,
required int remaining,
required int position,
required int counter,
}) : index = counter - remaining + position,
alignment = _getAlignment(position),
super(key: key);
Expand Down Expand Up @@ -231,9 +231,9 @@ class AvatarOverview extends StatelessWidget {

class AvatarWidget extends StatelessWidget {
const AvatarWidget({
Key key,
this.text,
this.color,
Key? key,
required this.text,
required this.color,
}) : super(key: key);

final String text;
Expand All @@ -255,7 +255,7 @@ class AvatarWidget extends StatelessWidget {

class CommandBar extends StatelessWidget {
const CommandBar({
Key key,
Key? key,
}) : super(key: key);

@override
Expand Down Expand Up @@ -295,20 +295,20 @@ class CommandBar extends StatelessWidget {

class MenuItemData {
const MenuItemData({
@required this.id,
required this.id,
this.label,
this.icon,
});

final String id;
final String label;
final IconData icon;
final String? label;
final IconData? icon;
}

class _MenuItem extends StatelessWidget {
const _MenuItem({
Key key,
@required this.data,
Key? key,
required this.data,
}) : super(key: key);

final MenuItemData data;
Expand All @@ -321,7 +321,7 @@ class _MenuItem extends StatelessWidget {
children: [
if (data.icon != null) Icon(data.icon),
if (data.icon != null && data.label != null) SizedBox(width: 8),
if (data.label != null) Text(data.label),
if (data.label != null) Text(data.label!),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ packages:
version: "2.1.0-nullsafety.5"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
flutter: ">=1.20.0 <2.0.0"
flutter: ">=1.24.0-10.2.pre <2.0.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0-0.0 <3.0.0"

dependencies:
flutter:
Expand Down
12 changes: 0 additions & 12 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,5 @@ void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
Loading

0 comments on commit a7a27b8

Please sign in to comment.