proste_indexed_stack 0.0.1 copy "proste_indexed_stack: ^0.0.1" to clipboard
proste_indexed_stack: ^0.0.1 copied to clipboard

outdated

Lazy load function of indexed stack, when the page is displayed for the first time, add the stack.

example/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyAppHome(),
    );
  }
}

class MyAppHome extends StatefulWidget {
  @override
  _MyAppHomeState createState() => _MyAppHomeState();
}

class _MyAppHomeState extends State<MyAppHome>
    with SingleTickerProviderStateMixin {
  int _current = 1;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: ProsteIndexedStack(
        index: _current,
        children: [
          HomePage(),
          MyPage(),
          Demo(),
          Demo2(),
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _current,
        onTap: (value) {
          setState(() {
            _current = value;
          });
        },
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
          BottomNavigationBarItem(icon: Icon(Icons.home), label: '我的'),
          BottomNavigationBarItem(icon: Icon(Icons.home), label: '参考'),
          BottomNavigationBarItem(icon: Icon(Icons.home), label: '测试'),
        ],
      ),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text('home'),
    );
  }
}

class MyPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print('profile');
    return Center(
      child: Text('Proifle'),
    );
  }
}

class Demo extends StatefulWidget {
  @override
  _DemoState createState() => _DemoState();
}

class _DemoState extends State<Demo> {
  @override
  void initState() {
    super.initState();
    print('demo load');
  }

  @override
  void dispose() {
    print('demo dispose');
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text('Demo'),
    );
  }
}

class Demo2 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text('Demo2'),
    );
  }
}
14
likes
0
pub points
90%
popularity

Publisher

unverified uploader

Lazy load function of indexed stack, when the page is displayed for the first time, add the stack.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on proste_indexed_stack