Question: Pleae helpme edit my dart code to make my app look like the provided picture. import 'package:flutter / material . dart'; import 'dart:math'; import 'package:shared

Pleae helpme edit my dart code to make my app look like the provided picture. import 'package:flutter/material.dart';
import 'dart:math';
import 'package:shared_preferences/shared_preferences.dart';
void main(){
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context){
return MaterialApp(
title: 'Random Student Picker',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: RandomStudentPicker(),
);
}
}
class RandomStudentPicker extends StatefulWidget {
@override
_RandomStudentPickerState createState()=>_RandomStudentPickerState();
}
class _RandomStudentPickerState extends State {
final List students =[];
final List hiddenStudents =[];
String selectedStudent ='';
@override
void initState(){
super.initState();
_loadStudents();
}
Future _loadStudents() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState((){
students.addAll(prefs.getStringList('students')??[]);
hiddenStudents.addAll(prefs.getStringList('hiddenStudents')??[]);
});
}
Future _saveStudents() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setStringList('students', students);
await prefs.setStringList('hiddenStudents', hiddenStudents);
}
void pickRandomStudent(){
setState((){
final List visibleStudents =
students.where((student)=>!hiddenStudents.contains(student)).toList();
if (visibleStudents.isNotEmpty){
final Random random = Random();
selectedStudent = visibleStudents[random.nextInt(visibleStudents.length)];
print('Selected Student: $selectedStudent');
} else {
print('No visible students available');
}
});
}
void toggleVisibility(String student){
setState((){
if (hiddenStudents.contains(student)){
hiddenStudents.remove(student);
} else {
hiddenStudents.add(student);
}
_saveStudents();
});
}
void addName(String name){
setState((){
students.add(name);
_saveStudents();
});
}
void deleteStudent(String student){
setState((){
students.remove(student);
hiddenStudents.remove(student); // Remove from hidden list as well
_saveStudents();
});
}
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(
title: Text('Random Student Picker'),
actions: [
IconButton(
icon: Icon(Icons.settings),
onPressed: (){
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Settings will be coming soon'),
),
);
},
),
IconButton(
icon: Icon(Icons.info),
onPressed: (){
// Navigate to about screen
Navigator.push(
context,
MaterialPageRoute(builder: (context)=> AboutScreen()),
);
},
),
],
),
body: ListView.builder(
itemCount: students.length,
itemBuilder: (context, index){
final student = students[index];
return Dismissible(
key: Key(student),
onDismissed: (direction){
deleteStudent(student);
},
background: Container(
color: Colors.red,
child: Icon(Icons.delete),
alignment: Alignment.centerRight,
),
child: ListTile(
title: Text(student),
onTap: (){
toggleVisibility(student);
},
leading: hiddenStudents.contains(student)
? Icon(Icons.visibility_off)
: null,
),
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: pickRandomStudent,
tooltip: 'Pick Random Student',
child: Icon(Icons.sync),
),
);
}
}
class AboutScreen extends StatelessWidget {
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(
title: Text('About'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'CSCI 4350',
style: TextStyle(fontSize: 24),
),
Image.asset(
'assets/piedmont_banner.png',
width: 200,
height: 200,
),
Text(
'Date: ${DateTime.now()}',
style: TextStyle(fontSize: 18),
),
Text(
'Developer: Your Name',
style: TextSty
 Pleae helpme edit my dart code to make my app look

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!