cupertino_route 0.0.2 copy "cupertino_route: ^0.0.2" to clipboard
cupertino_route: ^0.0.2 copied to clipboard

A Flutter package that provides a draggable page route.

example/lib/main.dart

import 'package:cupertino_route/cupertino_route.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Cupertino Route',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Cupertino Route'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  CupertinoRoute(
                    builder: (context) => const HorizontalListViewScreen(),
                  ),
                );
              },
              child: const Text('Horizontal list view'),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  CupertinoRoute(
                    builder: (context) => const TabBarViewScreen(),
                  ),
                );
              },
              child: const Text('Tab bar view'),
            ),
          ],
        ),
      ),
    );
  }
}

class HorizontalListViewScreen extends StatelessWidget {
  const HorizontalListViewScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Horizontal list view'),
      ),
      body: Column(
        children: [
          SizedBox(
            height: 500,
            child: ListView.builder(
              scrollDirection: Axis.horizontal,
              itemBuilder: (context, index) {
                return Container(
                  width: 150,
                  height: 500,
                  color: index % 2 == 0 ? Colors.black : Colors.red,
                );
              },
              itemCount: 20,
            ),
          ),
        ],
      ),
    );
  }
}

class TabBarViewScreen extends StatefulWidget {
  const TabBarViewScreen({super.key});

  @override
  State<TabBarViewScreen> createState() => _TabBarViewScreenState();
}

class _TabBarViewScreenState extends State<TabBarViewScreen>
    with SingleTickerProviderStateMixin {
  late final TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 3, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Tab bar view'),
      ),
      body: Column(
        children: [
          TabBar(
            tabs: const [
              Text('Tab 1'),
              Text('Tab 2'),
              Text('Tab 3'),
            ],
            controller: _tabController,
          ),
          Expanded(
            child: TabBarView(
              controller: _tabController,
              children: [
                Container(
                  color: Colors.red,
                ),
                Container(
                  color: Colors.blue,
                ),
                Container(
                  color: Colors.green,
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}
3
likes
140
points
39
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that provides a draggable page route.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, provider, vector_math

More

Packages that depend on cupertino_route