Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() {
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Split Screen App',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: SplitScreen(),
- );
- }
- }
- class SplitScreen extends StatefulWidget {
- @override
- _SplitScreenState createState() => _SplitScreenState();
- }
- class _SplitScreenState extends State<SplitScreen> {
- int _selectedIndex = 0;
- static const List<Widget> _views = [
- Center(child: Text('View 1')),
- Center(child: Text('View 2')),
- Center(child: Text('View 3')),
- ];
- void _onItemTapped(int index) {
- setState(() {
- _selectedIndex = index;
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Column(
- children: [
- Expanded(
- flex: 2,
- child: Image.network(
- 'https://picsum.photos/200',
- fit: BoxFit.cover,
- height: double.infinity,
- width: double.infinity,
- alignment: Alignment.center,
- ),
- ),
- Expanded(
- flex: 3,
- child: Scaffold(
- appBar: AppBar(
- title: Text('Split Screen'),
- actions: [
- IconButton(
- icon: Icon(Icons.emoji_emotions),
- onPressed: () {
- _onItemTapped(0);
- },
- ),
- IconButton(
- icon: Icon(Icons.emoji_events),
- onPressed: () {
- _onItemTapped(1);
- },
- ),
- IconButton(
- icon: Icon(Icons.emoji_flags),
- onPressed: () {
- _onItemTapped(2);
- },
- ),
- ],
- ),
- body: _views[_selectedIndex],
- ),
- ),
- ],
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement