MC Lab5&6
MC Lab5&6
231571
LAB 5 & 6
[Date]
Widgets
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
@override
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: WidgetDemo(),
);
@override
return Scaffold(
appBar: AppBar(
),
body: Padding(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Hello, Flutter!',
),
SizedBox(height: 16),
ElevatedButton(
onPressed: () {
print('Button Pressed!');
},
),
SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
],
),
SizedBox(height: 16),
Image.network(
'https://flutter.dev/images/flutter-logo-sharing.png',
height: 100,
width: 100,
),
SizedBox(height: 16),
Switch(
value: true,
onChanged: (bool value) {
},
),
],
),
),
);
}
Grid lines
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
@override
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: GridListDemo(),
);
'Item 1',
'Item 2',
'Item 3',
'Item 4',
'Item 5',
'Item 6',
];
@override
return Scaffold(
appBar: AppBar(
),
body: Padding(
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
),
itemCount: gridItems.length,
return Card(
elevation: 5,
child: Center(
child: Text(
gridItems[index],
),
),
);
},
),
),
);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
return MaterialApp(
home: FirstRoute(),
);
@override
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
);
},
),
),
);
}
class SecondRoute extends StatelessWidget {
@override
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
),
),
);
App