Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AppDeggendorf_Flutter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chaitanya Mangra
AppDeggendorf_Flutter
Commits
a486be5e
Commit
a486be5e
authored
2 years ago
by
Anager
Browse files
Options
Downloads
Patches
Plain Diff
added shared preferences
parent
dea9d537
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Home page chaitanya
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/bottom_navigation_bar_buttons/settings/settings.dart
+51
-44
51 additions, 44 deletions
lib/bottom_navigation_bar_buttons/settings/settings.dart
pubspec.lock
+1
-1
1 addition, 1 deletion
pubspec.lock
pubspec.yaml
+1
-0
1 addition, 0 deletions
pubspec.yaml
with
53 additions
and
45 deletions
lib/bottom_navigation_bar_buttons/settings/settings.dart
+
51
−
44
View file @
a486be5e
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
class
SettingScreen
extends
StatelessWidget
{
const
SettingScreen
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
...
...
@@ -40,12 +42,15 @@ class _DropdownSettingButtonState extends State<DropdownSettingButton> {
bool
_expanded
=
false
;
String
currentCity
=
"Deggendorf"
;
void
setCurrentCity
(
bool
isDeg
){
if
(
isDeg
){
currentCity
=
"Deggendorf"
;
}
else
{
currentCity
=
"Plattling"
;
}
getCurrentCityFromSharedPreferences
()
async
{
SharedPreferences
prefs
=
await
SharedPreferences
.
getInstance
();
String
val
=
prefs
.
getString
(
'currentCity'
)
??
"Not Selected"
;
currentCity
=
val
;
}
setCurrentCityInSharedPreferences
(
String
newCity
)
async
{
SharedPreferences
prefs
=
await
SharedPreferences
.
getInstance
();
prefs
.
setString
(
'currentCity'
,
newCity
);
}
...
...
@@ -55,44 +60,46 @@ class _DropdownSettingButtonState extends State<DropdownSettingButton> {
animationDuration:
Duration
(
microseconds:
2000
),
children:
[
ExpansionPanel
(
canTapOnHeader:
true
,
isExpanded:
_expanded
,
headerBuilder:
(
context
,
isExpanded
){
return
ListTile
(
title:
Text
(
"Aktuelle Stadt:
${currentCity}
"
,
style:
TextStyle
(
fontSize:
22
,
color:
Color
.
fromRGBO
(
1
,
1
,
1
,
0.49411764705882355
))
),
);
},
body:
Column
(
children:
<
Widget
>
[
TextButton
(
onPressed:
(){
setCurrentCity
(
true
);
_expanded
=
false
;
setState
(()
{
});
},
child:
Text
(
"Deggendorf"
,
style:
TextStyle
(
fontSize:
20
,
color:
Color
.
fromRGBO
(
1
,
1
,
1
,
0.49411764705882355
)),
)
),
TextButton
(
onPressed:
(){
setCurrentCity
(
false
);
_expanded
=
false
;
setState
(()
{
});
},
child:
Text
(
"Plattling"
,
style:
TextStyle
(
fontSize:
20
,
color:
Color
.
fromRGBO
(
1
,
1
,
1
,
0.49411764705882355
)),
)
),
],
)
canTapOnHeader:
true
,
isExpanded:
_expanded
,
headerBuilder:
(
context
,
isExpanded
){
return
ListTile
(
title:
Text
(
currentCity
,
style:
TextStyle
(
fontSize:
22
,
color:
Color
.
fromRGBO
(
1
,
1
,
1
,
0.49411764705882355
))
),
);
},
body:
Column
(
children:
<
Widget
>
[
TextButton
(
onPressed:
(){
setCurrentCityInSharedPreferences
(
"Deggendorf"
);
_expanded
=
false
;
getCurrentCityFromSharedPreferences
();
setState
(()
{
});
},
child:
Text
(
"Deggendorf"
,
style:
TextStyle
(
fontSize:
20
,
color:
Color
.
fromRGBO
(
1
,
1
,
1
,
0.49411764705882355
)),
)
),
TextButton
(
onPressed:
(){
setCurrentCityInSharedPreferences
(
"Plattling"
);
_expanded
=
false
;
getCurrentCityFromSharedPreferences
();
setState
(()
{
});
},
child:
Text
(
"Plattling"
,
style:
TextStyle
(
fontSize:
20
,
color:
Color
.
fromRGBO
(
1
,
1
,
1
,
0.49411764705882355
)),
)
),
],
)
)
],
expansionCallback:
(
panelIndex
,
isExpanded
){
...
...
This diff is collapsed.
Click to expand it.
pubspec.lock
+
1
−
1
View file @
a486be5e
...
...
@@ -269,7 +269,7 @@ packages:
source: hosted
version: "5.0.0"
shared_preferences:
dependency:
transitive
dependency:
"direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
...
...
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
1
−
0
View file @
a486be5e
...
...
@@ -37,6 +37,7 @@ dependencies:
cupertino_icons
:
^1.0.4
http
:
^0.13.4
flutter_settings_screens
:
^0.2.2+1
shared_preferences
:
^2.0.13
dev_dependencies
:
flutter_test
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment