Skip to content

Commit 64396cd

Browse files
null-safety migration completed
2 parents 9ba03b8 + 73602eb commit 64396cd

File tree

14 files changed

+394
-416
lines changed

14 files changed

+394
-416
lines changed

lib/components/badge/gf_button_badge.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class GFButtonBadge extends StatefulWidget {
2929
this.clipBehavior = Clip.none,
3030
this.focusNode,
3131
this.autofocus = false,
32-
// TODO(krishna)
32+
// TODO(krishna):
3333
MaterialTapTargetSize? materialTapTargetSize,
3434
this.type = GFButtonType.solid,
3535
this.shape = GFButtonShape.standard,

lib/components/bottom_sheet/gf_bottom_sheet.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class _GFBottomSheetState extends State<GFBottomSheet>
118118
_controllerListener = () {
119119
widget.controller.value ? _showBottomSheet() : _hideBottomSheet();
120120
};
121-
widget.controller.addListener(_controllerListener as void Function());
121+
widget.controller.addListener(_controllerListener);
122122
}
123123

124124
@override

lib/components/checkbox/gf_checkbox.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class GFCheckbox extends StatefulWidget {
4343
final Color inactiveBorderColor;
4444

4545
/// Called when the user checks or unchecks the checkbox.
46-
final ValueChanged<bool> onChanged;
46+
final ValueChanged<bool>? onChanged;
4747

4848
/// Used to set the current state of the checkbox
4949
final bool value;
@@ -85,7 +85,7 @@ class _GFCheckboxState extends State<GFCheckbox> {
8585
canRequestFocus: enabled,
8686
onTap: widget.onChanged != null
8787
? () {
88-
widget.onChanged(!widget.value);
88+
widget.onChanged!(!widget.value);
8989
}
9090
: null,
9191
child: Container(

lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class GFCheckboxListTile extends StatelessWidget {
8383
final Color inactiveBorderColor;
8484

8585
/// Called when the user checks or unchecks the checkbox.
86-
final ValueChanged<bool> onChanged;
86+
final ValueChanged<bool>? onChanged;
8787

8888
/// Used to set the current state of the checkbox
8989
final bool value;
@@ -133,7 +133,7 @@ class GFCheckboxListTile extends StatelessWidget {
133133
enabled: onChanged != null,
134134
onTap: onChanged != null
135135
? () {
136-
onChanged(!value);
136+
onChanged!(!value);
137137
}
138138
: null,
139139
selected: selected,

lib/components/drawer/gf_drawer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class GFDrawer extends StatelessWidget {
6464
this.colorFilter,
6565
this.gradient,
6666
this.color,
67-
}) : assert(elevation != null && elevation >= 0.0),
67+
}) : assert(elevation >= 0.0),
6868
super(key: key);
6969

7070
/// The z-coordinate at which to place this drawer relative to its parent.
@@ -117,7 +117,7 @@ class GFDrawer extends StatelessWidget {
117117
break;
118118
case TargetPlatform.android:
119119
case TargetPlatform.fuchsia:
120-
label = semanticLabel ?? MaterialLocalizations.of(context)?.drawerLabel;
120+
label = semanticLabel ?? MaterialLocalizations.of(context).drawerLabel;
121121
break;
122122
default:
123123
break;

lib/components/radio/gf_radio.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class GFRadio<T> extends StatefulWidget {
5454
final Color inactiveBorderColor;
5555

5656
/// Called when the user checks or unchecks the radio button
57-
final ValueChanged<T> onChanged;
57+
final ValueChanged<T>? onChanged;
5858

5959
///type of Widget used to change the radio button's active icon
6060
final Widget activeIcon;
@@ -99,7 +99,7 @@ class _GFRadioState<T> extends State<GFRadio<T>> with TickerProviderStateMixin {
9999
void _handleChanged(bool selected) {
100100

101101
if (selected) {
102-
widget.onChanged(widget.value);
102+
widget.onChanged!(widget.value);
103103
}
104104
}
105105

lib/components/radio_list_tile/gf_radio_list_tile.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class GFRadioListTile<T> extends StatelessWidget {
137137
final Color inactiveBorderColor;
138138

139139
/// Called when the user checks or unchecks the checkbox.
140-
final ValueChanged<dynamic> onChanged;
140+
final ValueChanged<dynamic>? onChanged;
141141

142142
///type of Widget used to change the checkbox's active icon
143143
final Widget activeIcon;
@@ -186,11 +186,11 @@ class GFRadioListTile<T> extends StatelessWidget {
186186
onTap: onChanged != null
187187
? () {
188188
if (toggleable && checked) {
189-
onChanged(null);
189+
onChanged!(null);
190190
return;
191191
}
192192
if (!checked) {
193-
onChanged(value);
193+
onChanged!(value);
194194
}
195195
}
196196
: null,

lib/components/sticky_header/render_gf_sticky_header.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class RenderGFStickyHeader extends RenderBox
159159
}
160160
child.layout(innerConstraints, parentUsesSize: true);
161161
allottedSize += _getMainSize(child);
162-
crossSize = math.max(crossSize, _getCrossSize(child)!);
162+
crossSize = math.max(crossSize, _getCrossSize(child));
163163
}
164164
assert(child.parentData == childParentData);
165165
child = childParentData?.nextSibling;

lib/components/tabs/gf_tabbar_view.dart

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,19 @@ class _GFTabBarViewState extends State<GFTabBarView> {
127127
}
128128

129129
void _handleTabControllerAnimationTick() {
130-
if (_warpUnderwayCount > 0 || !_controller!.indexIsChanging) {
131-
return;
132-
} // This widget is driving the controller's animation.
133-
if (_controller!.index != _currentIndex) {
134-
_currentIndex = _controller!.index;
135-
_warpToCurrentIndex();
130+
if (_controller != null) {
131+
if (_warpUnderwayCount > 0 || !_controller!.indexIsChanging) {
132+
return;
133+
} // This widget is driving the controller's animation.
134+
if (_controller!.index != _currentIndex) {
135+
_currentIndex = _controller!.index;
136+
_warpToCurrentIndex();
137+
}
136138
}
137139
}
138140

139141
Future<void> _warpToCurrentIndex() async {
140-
if (!mounted) {
142+
if (!mounted || _pageController == null || _currentIndex == null) {
141143
return Future<void>.value();
142144
}
143145

@@ -188,6 +190,12 @@ class _GFTabBarViewState extends State<GFTabBarView> {
188190
if (notification.depth != 0) {
189191
return false;
190192
}
193+
if (_controller == null ||
194+
_pageController == null ||
195+
_pageController?.page != null ||
196+
_controller?.index == null) {
197+
return false;
198+
}
191199

192200
_warpUnderwayCount += 1;
193201
if (notification is ScrollUpdateNotification &&
@@ -209,9 +217,9 @@ class _GFTabBarViewState extends State<GFTabBarView> {
209217
@override
210218
Widget build(BuildContext context) {
211219
assert(() {
212-
if (_controller!.length != widget.children.length) {
220+
if (_controller?.length != widget.children.length) {
213221
throw FlutterError(
214-
'Controller\'s length property (${_controller!.length}) does not match the \n'
222+
'Controller\'s length property (${_controller?.length}) does not match the \n'
215223
'number of tabs (${widget.children.length}) present in TabBar\'s tabs property.');
216224
}
217225
return true;

lib/components/toggle/gf_toggle.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ class _GFToggleState extends State<GFToggle> with TickerProviderStateMixin {
104104

105105
@override
106106
void dispose() {
107-
if (animationController != null) {
108-
animationController!.dispose();
109-
}
107+
108+
animationController?.dispose();
109+
110110
controller.dispose();
111111
super.dispose();
112112
}

0 commit comments

Comments
 (0)