0% found this document useful (0 votes)
31 views2 pages

Lab Ex 1

This document contains a Flutter application that implements a simple counter app. The app increments a counter by 4 each time a button is pressed. It features a basic user interface with an AppBar and a centered column displaying the counter value and a button.

Uploaded by

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

Lab Ex 1

This document contains a Flutter application that implements a simple counter app. The app increments a counter by 4 each time a button is pressed. It features a basic user interface with an AppBar and a centered column displaying the counter value and a button.

Uploaded by

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

import 'package:flutter/material.

dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Countup by 4 App',
home: CounterScreen(),
);
}
}
class counterScreen extends statefulWidget {
@override
_CounterScreenState createState() => _CounterScreenState();
}
class _CounterScreenState extends State {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter = 4; // Increment by 4
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Count up by 4'),
),
body: Center(
child: Column(
MainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Counter:',
style: TextStyle(fontSize: 24),
),
Text(
'$_counter',
style: TextStyle(fontSize: 48, fontWeight: FontWeight.bold),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: _incrementCounter,
child: Text('Count up by 4'),
),
],
),
),
);
}
}

You might also like