flutter: Migrate to null-safety (4, fix runtime warnings)
This commit is contained in:
parent
68bc5a4551
commit
647e72b19b
|
@ -125,7 +125,7 @@ class Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
select(int pos) {
|
select(int pos) {
|
||||||
_focusIndex = pos ?? Move.invalidMove;
|
_focusIndex = pos;
|
||||||
_blurIndex = Move.invalidMove;
|
_blurIndex = Move.invalidMove;
|
||||||
//Audios.playTone('click.mp3');
|
//Audios.playTone('click.mp3');
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ class _DrawerUserControllerState extends State<DrawerUserController>
|
||||||
ScrollController(initialScrollOffset: widget.drawerWidth);
|
ScrollController(initialScrollOffset: widget.drawerWidth);
|
||||||
scrollController
|
scrollController
|
||||||
..addListener(() {
|
..addListener(() {
|
||||||
if (scrollController!.offset <= 0) {
|
if (scrollController.offset <= 0) {
|
||||||
if (scrolloffset != 1.0) {
|
if (scrolloffset != 1.0) {
|
||||||
setState(() {
|
setState(() {
|
||||||
scrolloffset = 1.0;
|
scrolloffset = 1.0;
|
||||||
|
@ -57,13 +57,13 @@ class _DrawerUserControllerState extends State<DrawerUserController>
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
iconAnimationController!.animateTo(0.0,
|
iconAnimationController.animateTo(0.0,
|
||||||
duration: const Duration(milliseconds: 0),
|
duration: const Duration(milliseconds: 0),
|
||||||
curve: Curves.fastOutSlowIn);
|
curve: Curves.fastOutSlowIn);
|
||||||
} else if (scrollController!.offset > 0 &&
|
} else if (scrollController.offset > 0 &&
|
||||||
scrollController!.offset < widget.drawerWidth.floor()) {
|
scrollController.offset < widget.drawerWidth.floor()) {
|
||||||
iconAnimationController!.animateTo(
|
iconAnimationController.animateTo(
|
||||||
(scrollController!.offset * 100 / (widget.drawerWidth)) / 100,
|
(scrollController.offset * 100 / (widget.drawerWidth)) / 100,
|
||||||
duration: const Duration(milliseconds: 0),
|
duration: const Duration(milliseconds: 0),
|
||||||
curve: Curves.fastOutSlowIn);
|
curve: Curves.fastOutSlowIn);
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,7 +75,7 @@ class _DrawerUserControllerState extends State<DrawerUserController>
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
iconAnimationController!.animateTo(1.0,
|
iconAnimationController.animateTo(1.0,
|
||||||
duration: const Duration(milliseconds: 0),
|
duration: const Duration(milliseconds: 0),
|
||||||
curve: Curves.fastOutSlowIn);
|
curve: Curves.fastOutSlowIn);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ class _DrawerUserControllerState extends State<DrawerUserController>
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> getInitState() async {
|
Future<bool> getInitState() async {
|
||||||
scrollController!.jumpTo(
|
scrollController.jumpTo(
|
||||||
widget.drawerWidth,
|
widget.drawerWidth,
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
|
@ -110,12 +110,12 @@ class _DrawerUserControllerState extends State<DrawerUserController>
|
||||||
//we divided first drawer Width with HomeDrawer and second full-screen Width with all home screen, we called screen View
|
//we divided first drawer Width with HomeDrawer and second full-screen Width with all home screen, we called screen View
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
child: AnimatedBuilder(
|
child: AnimatedBuilder(
|
||||||
animation: iconAnimationController!,
|
animation: iconAnimationController,
|
||||||
builder: (BuildContext context, Widget? child) {
|
builder: (BuildContext context, Widget? child) {
|
||||||
return Transform(
|
return Transform(
|
||||||
//transform we use for the stable drawer we, not need to move with scroll view
|
//transform we use for the stable drawer we, not need to move with scroll view
|
||||||
transform: Matrix4.translationValues(
|
transform: Matrix4.translationValues(
|
||||||
scrollController!.offset, 0.0, 0.0),
|
scrollController.offset, 0.0, 0.0),
|
||||||
child: HomeDrawer(
|
child: HomeDrawer(
|
||||||
screenIndex: widget.screenIndex == null
|
screenIndex: widget.screenIndex == null
|
||||||
? DrawerIndex.humanVsAi
|
? DrawerIndex.humanVsAi
|
||||||
|
@ -179,7 +179,7 @@ class _DrawerUserControllerState extends State<DrawerUserController>
|
||||||
: AnimatedIcon(
|
: AnimatedIcon(
|
||||||
icon: widget.animatedIconData,
|
icon: widget.animatedIconData,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
progress: iconAnimationController!),
|
progress: iconAnimationController),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
FocusScope.of(context)
|
FocusScope.of(context)
|
||||||
|
@ -203,14 +203,14 @@ class _DrawerUserControllerState extends State<DrawerUserController>
|
||||||
|
|
||||||
void onDrawerClick() {
|
void onDrawerClick() {
|
||||||
//if scrollcontroller.offset != 0.0 then we set to closed the drawer(with animation to offset zero position) if is not 1 then open the drawer
|
//if scrollcontroller.offset != 0.0 then we set to closed the drawer(with animation to offset zero position) if is not 1 then open the drawer
|
||||||
if (scrollController!.offset != 0.0) {
|
if (scrollController.offset != 0.0) {
|
||||||
scrollController!.animateTo(
|
scrollController.animateTo(
|
||||||
0.0,
|
0.0,
|
||||||
duration: const Duration(milliseconds: 400),
|
duration: const Duration(milliseconds: 400),
|
||||||
curve: Curves.fastOutSlowIn,
|
curve: Curves.fastOutSlowIn,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
scrollController!.animateTo(
|
scrollController.animateTo(
|
||||||
widget.drawerWidth,
|
widget.drawerWidth,
|
||||||
duration: const Duration(milliseconds: 400),
|
duration: const Duration(milliseconds: 400),
|
||||||
curve: Curves.fastOutSlowIn,
|
curve: Curves.fastOutSlowIn,
|
||||||
|
|
Loading…
Reference in New Issue