Skip to content

Commit

Permalink
Migrate to NNBD (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jjagg authored Jan 28, 2021
1 parent 0cccc25 commit c76661b
Show file tree
Hide file tree
Showing 15 changed files with 242 additions and 571 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
channel:
- dev
- stable
# - stable

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ lib/generated_plugin_registrant.dart

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

pubspec.lock
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.4.0-nullsafety.0

Migrated to null-safety (thanks to @Jjagg!)

# 0.3.0

- Improved the dart-doc of Portal and PortalEntry
Expand Down
24 changes: 12 additions & 12 deletions example/lib/contextual_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:flutter_portal/flutter_portal.dart';
void main() => runApp(const MyApp());

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

@override
Widget build(BuildContext context) {
Expand All @@ -28,7 +28,7 @@ class MyApp extends StatelessWidget {
}

class ContextualMenuExample extends StatefulWidget {
const ContextualMenuExample({Key key}) : super(key: key);
const ContextualMenuExample({Key? key}) : super(key: key);

@override
_ContextualMenuExampleState createState() => _ContextualMenuExampleState();
Expand Down Expand Up @@ -57,7 +57,7 @@ class _ContextualMenuExampleState extends State<ContextualMenuExample> {
),
],
),
child: RaisedButton(
child: ElevatedButton(
onPressed: () => setState(() => _showMenu = true),
child: const Text('show menu'),
),
Expand All @@ -68,8 +68,8 @@ class _ContextualMenuExampleState extends State<ContextualMenuExample> {

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

final List<Widget> children;
Expand All @@ -93,13 +93,13 @@ class Menu extends StatelessWidget {

class ModalEntry extends StatelessWidget {
const ModalEntry({
Key key,
this.onClose,
this.menu,
this.visible,
this.menuAnchor,
this.childAnchor,
this.child,
Key? key,
required this.onClose,
required this.menu,
required this.visible,
required this.menuAnchor,
required this.childAnchor,
required this.child,
}) : super(key: key);

final VoidCallback onClose;
Expand Down
20 changes: 10 additions & 10 deletions example/lib/date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ void main() => runApp(const MyApp());

class DeclarativeDatePicker extends StatelessWidget {
const DeclarativeDatePicker({
Key key,
this.visible,
this.onDismissed,
this.onClose,
this.child,
Key? key,
required this.visible,
required this.onDismissed,
required this.onClose,
required this.child,
}) : super(key: key);

final bool visible;
Expand All @@ -36,7 +36,7 @@ class DeclarativeDatePicker extends StatelessWidget {
child: Center(
child: Card(
elevation: 16,
child: RaisedButton(
child: ElevatedButton(
onPressed: () => onClose(DateTime.now()),
child: const Text('today'),
),
Expand All @@ -51,7 +51,7 @@ class DeclarativeDatePicker extends StatelessWidget {
}

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

@override
Widget build(BuildContext context) {
Expand All @@ -73,14 +73,14 @@ class MyApp extends StatelessWidget {
}

class DatePickerUsageExample extends StatefulWidget {
const DatePickerUsageExample({Key key}) : super(key: key);
const DatePickerUsageExample({Key? key}) : super(key: key);

@override
_DatePickerUsageExampleState createState() => _DatePickerUsageExampleState();
}

class _DatePickerUsageExampleState extends State<DatePickerUsageExample> {
DateTime pickedDate;
DateTime? pickedDate;
bool showDatePicker = false;

@override
Expand All @@ -94,7 +94,7 @@ class _DatePickerUsageExampleState extends State<DatePickerUsageExample> {
}),
onDismissed: () => setState(() => showDatePicker = false),
child: pickedDate == null
? RaisedButton(
? ElevatedButton(
onPressed: () => setState(() => showDatePicker = true),
child: const Text('pick a date'),
)
Expand Down
33 changes: 21 additions & 12 deletions example/lib/discovery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void main() {
}

class MyApp extends StatefulWidget {
const MyApp({Key key}) : super(key: key);
const MyApp({Key? key}) : super(key: key);

@override
_MyAppState createState() => _MyAppState();
Expand All @@ -28,7 +28,7 @@ class _MyAppState extends State<MyApp> {
children: [
const Text('You have clicked the button this many times:'),
Text('$count', style: Theme.of(context).textTheme.headline4),
RaisedButton(
ElevatedButton(
onPressed: () => setState(() => showDiscovery = true),
child: const Text('Show discovery'),
)
Expand Down Expand Up @@ -59,11 +59,11 @@ class _MyAppState extends State<MyApp> {

class Discovery extends StatelessWidget {
const Discovery({
Key key,
@required this.visible,
@required this.onClose,
@required this.description,
@required this.child,
Key? key,
required this.visible,
required this.onClose,
required this.description,
required this.child,
}) : super(key: key);

final Widget child;
Expand Down Expand Up @@ -102,7 +102,7 @@ class Discovery extends StatelessWidget {
left: 50,
width: 200,
child: DefaultTextStyle(
style: Theme.of(context).textTheme.headline5,
style: Theme.of(context).textTheme.headline5!,
child: TweenAnimationBuilder<double>(
duration: kThemeAnimationDuration,
curve: Curves.easeOut,
Expand Down Expand Up @@ -157,10 +157,10 @@ class HolePainter extends CustomPainter {

class Barrier extends StatelessWidget {
const Barrier({
Key key,
@required this.onClose,
@required this.visible,
@required this.child,
Key? key,
required this.onClose,
required this.visible,
required this.child,
}) : super(key: key);

final Widget child;
Expand Down Expand Up @@ -190,3 +190,12 @@ class Barrier extends StatelessWidget {
);
}
}

/// Non-nullable version of ColorTween.
class ColorTween extends Tween<Color> {
ColorTween({required Color begin, required Color end})
: super(begin: begin, end: end);

@override
Color lerp(double t) => Color.lerp(begin, end, t)!;
}
8 changes: 4 additions & 4 deletions example/lib/medium_clap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter_portal/flutter_portal.dart';
void main() => runApp(const MyApp());

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

@override
Widget build(BuildContext context) {
Expand All @@ -26,7 +26,7 @@ class MyApp extends StatelessWidget {
}

class ClapButton extends StatefulWidget {
const ClapButton({Key key}) : super(key: key);
const ClapButton({Key? key}) : super(key: key);

@override
_ClapButtonState createState() => _ClapButtonState();
Expand All @@ -35,7 +35,7 @@ class ClapButton extends StatefulWidget {
class _ClapButtonState extends State<ClapButton> {
int clapCount = 0;
bool hasClappedRecently = false;
Timer resetHasClappedRecentlyTimer;
Timer? resetHasClappedRecentlyTimer;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -64,7 +64,7 @@ class _ClapButtonState extends State<ClapButton> {
child: Text('$clapCount'),
),
),
child: RaisedButton(
child: ElevatedButton(
onPressed: _clap,
child: const Icon(Icons.plus_one),
),
Expand Down
31 changes: 20 additions & 11 deletions example/lib/modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void main() {
}

class MyApp extends StatefulWidget {
const MyApp({Key key}) : super(key: key);
const MyApp({Key? key}) : super(key: key);

@override
_MyAppState createState() => _MyAppState();
Expand All @@ -28,7 +28,7 @@ class _MyAppState extends State<MyApp> {
child: Text('Hello world'),
),
onClose: () => setState(() => showModal = false),
child: RaisedButton(
child: ElevatedButton(
onPressed: () => setState(() => showModal = true),
child: const Text('Show modal'),
),
Expand All @@ -42,11 +42,11 @@ class _MyAppState extends State<MyApp> {

class Modal extends StatelessWidget {
const Modal({
Key key,
@required this.visible,
@required this.onClose,
@required this.modal,
@required this.child,
Key? key,
required this.visible,
required this.onClose,
required this.modal,
required this.child,
}) : super(key: key);

final Widget child;
Expand Down Expand Up @@ -85,10 +85,10 @@ class Modal extends StatelessWidget {

class Barrier extends StatelessWidget {
const Barrier({
Key key,
@required this.onClose,
@required this.visible,
@required this.child,
Key? key,
required this.onClose,
required this.visible,
required this.child,
}) : super(key: key);

final Widget child;
Expand Down Expand Up @@ -118,3 +118,12 @@ class Barrier extends StatelessWidget {
);
}
}

/// Non-nullable version of ColorTween.
class ColorTween extends Tween<Color> {
ColorTween({required Color begin, required Color end})
: super(begin: begin, end: end);

@override
Color lerp(double t) => Color.lerp(begin, end, t)!;
}
Loading

0 comments on commit c76661b

Please sign in to comment.