Skip to content

Commit

Permalink
trial and error failure for the shared preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-chiemerie committed Jan 13, 2024
1 parent 8894d4d commit 68ef885
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 72 deletions.
5 changes: 3 additions & 2 deletions lib/screens/avatar_name/avatar_select.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:kiddytunes/data/avatarlis.dart';
import 'package:kiddytunes/screens/avatar_name/name_entry.dart';
import 'package:kiddytunes/screens/mainscreens/homescreen.dart';
import 'package:shared_preferences/shared_preferences.dart';

class Avatar extends StatefulWidget {
Expand Down Expand Up @@ -120,14 +121,14 @@ class _AvatarState extends State<Avatar> {
setState(() {
selectedindex = _controller.page?.round() ?? 0;
});
_disablePref();
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
Namesscreen(selectedindex: selectedindex),
),
);
_disablePref();
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
Expand All @@ -146,6 +147,6 @@ class _AvatarState extends State<Avatar> {
),
),
)
: Namesscreen(selectedindex: selectedindex);
: const Homescreen();
}
}
135 changes: 66 additions & 69 deletions lib/screens/avatar_name/name_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hive/hive.dart';
import 'package:kiddytunes/data/avatarlis.dart';
import 'package:kiddytunes/screens/mainscreens/homescreen.dart';
import 'package:shared_preferences/shared_preferences.dart';

class Namesscreen extends StatefulWidget {
Expand Down Expand Up @@ -48,76 +47,74 @@ class _NamesscreenState extends State<Namesscreen> {

@override
Widget build(BuildContext context) {
return onboard
? Scaffold(
backgroundColor: Theme.of(context).primaryColor,
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 70,
),
//the avatar
Center(
child: Container(
margin: const EdgeInsets.all(10),
height: 170,
width: 100,
child: SvgPicture.asset(
avatarstrings[widget.selectedindex],
),
),
),
//the text field
Padding(
padding: const EdgeInsets.all(20),
child: Text(
'Enter your name',
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(color: Colors.white),
),
),
//the text field
SizedBox(
height: 64,
width: 274,
child: TextField(
controller: _texty,
maxLength: 8,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: MediaQuery.of(context).size.width * 0.05,
color: Colors.black,
),
textAlign: TextAlign.justify,
cursorColor: Theme.of(context).primaryColor,
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
hintText: 'Brandon',
hintStyle: const TextStyle(color: Colors.grey),
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(14),
),
),
return Scaffold(
backgroundColor: Theme.of(context).primaryColor,
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 70,
),
//the avatar
Center(
child: Container(
margin: const EdgeInsets.all(10),
height: 170,
width: 100,
child: SvgPicture.asset(
avatarstrings[widget.selectedindex],
),
),
),
//the text field
Padding(
padding: const EdgeInsets.all(20),
child: Text(
'Enter your name',
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(color: Colors.white),
),
),
//the text field
SizedBox(
height: 64,
width: 274,
child: TextField(
controller: _texty,
maxLength: 8,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: MediaQuery.of(context).size.width * 0.05,
color: Colors.black,
),
textAlign: TextAlign.justify,
cursorColor: Theme.of(context).primaryColor,
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
hintText: 'Brandon',
hintStyle: const TextStyle(color: Colors.grey),
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(14),
),
],
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.transparent,
elevation: 0,
splashColor: Colors.white,
onPressed: () {
Navigator.pushNamed(context, '/home');
addname();
_disablePref();
},
child: SvgPicture.asset('assets/images/next.svg'),
),
),
)
: const Homescreen();
),
],
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.transparent,
elevation: 0,
splashColor: Colors.white,
onPressed: () {
Navigator.pushNamed(context, '/home');
addname();
_disablePref();
},
child: SvgPicture.asset('assets/images/next.svg'),
),
);
}
}
2 changes: 1 addition & 1 deletion lib/screens/onboard/onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class _OnboardOneState extends State<OnboardOne> {
height: 52,
child: MaterialButton(
onPressed: () {
Navigator.push(
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => const Avatar(),
Expand Down

0 comments on commit 68ef885

Please sign in to comment.