g_faraday 0.6.0-nullsafety.32 copy "g_faraday: ^0.6.0-nullsafety.32" to clipboard
g_faraday: ^0.6.0-nullsafety.32 copied to clipboard

outdated

A very simple plugin for building hybrid stack apps with flutter

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:g_faraday/g_faraday.dart';

import 'src/pages/features/basic/pages/flutter_to_flutter.dart';
import 'src/pages/features/basic/pages/native_to_flutter.dart';
import 'src/pages/features/basic/pages/tab_page.dart';
import 'src/pages/features/basic/pages/transparent_page.dart';
import 'src/pages/home_page.dart';
import 'src/utils/observer.dart';
import 'src/utils/simple_localizations.dart';

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

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

class _MyAppState extends State<MyApp> {
  Map<String, RouteFactory> routes = {
    'home': (settings) => CupertinoPageRoute(
        builder: (context) => HomePage(settings.arguments), settings: settings),
    'native2flutter': (settings) => CupertinoPageRoute(
        builder: (context) => Native2FlutterPage(settings.arguments),
        settings: settings),
    'flutter2flutter': (settings) => CupertinoPageRoute(
        builder: (context) => Flutter2Flutter(index: settings.toJson.index),
        settings: settings),
    'tab1': (settings) =>
        CupertinoPageRoute(builder: (context) => TabPage(), settings: settings),
    'transparent_flutter': (settings) => CupertinoPageRoute(
          builder: (context) => TransparentPage(),
          settings: settings,
        )
  };

  @override
  Widget build(BuildContext context) {
    final color = Color.fromARGB(255, 6, 210, 116);

    final route = faraday.wrapper(
      (settings) => routes[settings.name]?.call(settings),
      observers: [DemoObserver()],
      // switchPageAnimation: (currentRoute) {
      //   if (currentRoute['route'] == '') {
      //     return ((context, child) => AnimatedSwitcher(
      //           duration: Duration(seconds: 1),
      //           child: child,
      //           transitionBuilder: (child, animation) => RotationTransition(
      //             turns: animation,
      //             child: child,
      //           ),
      //         ));
      //   }
      //   return null;
      // },
      // flutter 自定义过渡页背景
      // nativeContainerBackgroundColorProvider: (context, {route}) =>
      //     CupertinoColors.secondarySystemBackground,
    );

    final cupertinoApp = CupertinoApp(
      localizationsDelegates: [
        S.delegate,
        DefaultCupertinoLocalizations.delegate
      ],
      supportedLocales: [
        Locale('en', ''),
        Locale.fromSubtags(languageCode: 'zh')
      ],
      theme: CupertinoThemeData(primaryColor: color),
      debugShowCheckedModeBanner: false,
      onGenerateRoute: (_) => route,
    );

    return Directionality(
      textDirection: TextDirection.ltr,
      child: Banner(
        location: BannerLocation.topEnd,
        message: 'faraday',
        color: color,
        textStyle: TextStyle(
          color: CupertinoColors.white,
          fontSize: 12 * 0.85,
          fontWeight: FontWeight.w900,
          height: 1.0,
        ),
        child: cupertinoApp,
      ),
    );
  }
}
10
likes
0
pub points
38%
popularity

Publisher

verified publisherfaraday.icu

A very simple plugin for building hybrid stack apps with flutter

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, g_json

More

Packages that depend on g_faraday