flutter_boost 0.0.343 copy "flutter_boost: ^0.0.343" to clipboard
flutter_boost: ^0.0.343 copied to clipboard

outdated

A new Flutter plugin make flutter better to use!

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:flutter_boost/container/boost_container.dart';

class HomeRoute extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

class FirstRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('First Route'),
      ),
      body: Center(
        child: RaisedButton(
          child: Text('Open second route'),
          onPressed: () {
            FlutterBoost.singleton.openPage("second", {}, true);
          },
        ),
      ),
    );
  }
}

class SecondRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Second Route"),
      ),
      body: Center(
        child: RaisedButton(
          onPressed: () {
            // Navigate back to first route when tapped.
            FlutterBoost.singleton.closePageForContext(context);
            
          },
          child: Text('Go back!'),
        ),
      ),
    );
  }
}

class TabRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Tab Route"),
      ),
      body: Center(
        child: RaisedButton(
          onPressed: () {
            FlutterBoost.singleton.openPage("second", {}, true);
          },
          child: Text('Open second route'),
        ),
      ),
    );
  }
}

void main() {

  FlutterBoost.singleton.registerPageBuilder("first", (String pageName, Map params, String uniqueId){
    return FirstRoute();
  });

  FlutterBoost.singleton.registerPageBuilder("second", (String pageName, Map params, String uniqueId){
    return SecondRoute();
  });

  FlutterBoost.singleton.registerPageBuilder("tab", (String pageName, Map params, String uniqueId){
    return TabRoute();
  });

  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Boost example',
        builder: FlutterBoost.init(),
        home: HomeRoute());
  }
}