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: CustomScrollView(
- slivers: [
- SliverAppBar(
- title: Text('Split Screen'),
- floating: true,
- 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);
- },
- ),
- ],
- ),
- SliverFillRemaining(
- child: AnimatedSwitcher(
- duration: Duration(milliseconds: 500),
- child: _views[_selectedIndex],
- ),
- ),
- ],
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement