0% found this document useful (0 votes)
18 views

Assignment

Uploaded by

s13013660
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Assignment

Uploaded by

s13013660
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Name – Sanskar Jain

Enrollment NO. – A60205222026


Section – A
Semester – 5th
Subject – Introduction To Android Development
Batch – 2022-2026

Ǫues-1 wirte the flutter code app using container row column icon with listview.
Ans:-

import 'package:flutter/material.dart';

void main() {

runApp(MyApp());

class MyApp extends StatelessWidget {

@override

Widget build(BuildContext context) {

return MaterialApp(

title: 'Flutter ListView Example',

theme: ThemeData(

primarySwatch: Colors.blue,

),

home: MyHomePage(),

);

}
class MyHomePage extends StatelessWidget {

final List<String> items = List.generate(20, (index) => 'Item $index');

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text('ListView with Icons'),

),

body: ListView.builder(
itemCount: items.length, itemBuilder:

(context, index) { return Container(

margin: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),

padding: EdgeInsets.all(12.0),

decoration: BoxDecoration(

color: Colors.blue.shade100,

borderRadius: BorderRadius.circular(10.0),

boxShadow: [

BoxShadow(

color: Colors.black26,

blurRadius: 4.0,

offset: Offset(2.0, 2.0),

),
],

),

child: Row(

children: [

Icon(

Icons.star,

color: Colors.orange,

size: 30.0,

),

SizedBox(width: 16.0),

Expanded(

child: Column(

crossAxisAlignment: CrossAxisAlignment.start,

children: [

Text(

items[index],

style: TextStyle(
fontSize: 18.0,

fontWeight: FontWeight.bold,

),

),

SizedBox(height: 4.0),

Text(

'Description of ${items[index]}',

style: TextStyle(

fontSize: 14.0,

color: Colors.grey,

),

),

],

),

),

Icon(

Icons.chevron_right,

color: Colors.blue,

),

],

),

);

},

),

);

import 'package:flutter/material.dart';

void main() {
runApp(MyApp());

class MyApp extends StatelessWidget {

@override

Widget build(BuildContext context) {

return MaterialApp(

home: TaskListScreen(),

);

class TaskListScreen extends StatefulWidget {

@override

_TaskListScreenState createState() => _TaskListScreenState();

class _TaskListScreenState extends State<TaskListScreen> {

// List of tasks with their completion status

List<Task> tasks = [

Task(title: 'Buy groceries', isCompleted: false),

Task(title: 'Walk the dog', isCompleted: true),

Task(title: 'Workout', isCompleted: false),

Task(title: 'Read a book', isCompleted: true),

Task(title: 'Learn Flutter', isCompleted: false),

];

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(
title: Text('Task List'),

),

body: Column(

children: [

// Header Section

Padding(

padding: const EdgeInsets.all(16.0),

child: Row(

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Text(

'Your Tasks',

style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),

),

IconButton(

icon: Icon(Icons.add),

onPressed: () {

setState(() {

tasks.add(Task(title: 'New Task', isCompleted: false));

});

},

),

],

),

),

// Task List Section

Expanded(

child: ListView.builder(

itemCount: tasks.length,

itemBuilder: (context, index) {

return TaskItem(
task: tasks[index],

onChanged: (bool? value) {

setState(() {

tasks[index].isCompleted = value ?? false;

});

},

);

},

),

),

],

),

);

// Task model

class Task {

String title;

bool isCompleted;

Task({required this.title, this.isCompleted = false});

// Task item widget

class TaskItem extends StatelessWidget {

final Task task;

final ValueChanged<bool?> onChanged;

TaskItem({required this.task, required this.onChanged});


@override

Widget build(BuildContext context) {

return Padding(

padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),

child: Row(

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Text(

task.title,

style: TextStyle(

fontSize: 18,

decoration:

task.isCompleted ? TextDecoration.lineThrough : null,

),

),

Checkbox(

value: task.isCompleted,

onChanged: onChanged,
),

],

),

);

}
}

You might also like