fl_extended 0.4.1 copy "fl_extended: ^0.4.1" to clipboard
fl_extended: ^0.4.1 copied to clipboard

Some extension components and methods have been added to flutter and the routing functionality has been simplified

example/lib/main.dart

import 'package:example/src/module/animation_page.dart';
import 'package:example/src/module/builder_page.dart';
import 'package:example/src/module/button_page.dart';
import 'package:example/src/module/icon_box_page.dart';
import 'package:example/src/module/state_components_page.dart';
import 'package:example/src/module/text_page.dart';
import 'package:example/src/module/decorator_page.dart';
import 'package:example/src/module/list_wheel_page.dart';
import 'package:example/src/module/overlay_page.dart';
import 'package:example/src/module/popup_page.dart';
import 'package:example/src/module/refresh_page.dart';
import 'package:example/src/module/scroll_list_page.dart';
import 'package:example/src/module/scroll_page.dart';
import 'package:example/src/module/text_field_page.dart';
import 'package:example/src/module/universal_page.dart';
import 'package:device_preview_minus/device_preview_minus.dart';
import 'package:example/src/scaffold.dart';
import 'package:example/src/theme.dart';
import 'package:fl_extended/fl_extended.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  FlExtended flExtended = FlExtended();

  flExtended.pushStyle = RoutePushStyle.material;

  /// 设置全局Toast配置
  flExtended.toastOptions = ToastOptions(
      addMaterial: true,
      animationStyle: FlAnimationStyle.fade,
      onModalTap: closeToast,
      decoration: BoxDecoration(
          color: Colors.grey, borderRadius: BorderRadius.circular(4)),
      builder: (String text, IconData? icon, Color? color) {
        return Universal(
            margin: const EdgeInsets.all(10),
            mainAxisSize: MainAxisSize.min,
            children: [
              if (icon != null) Icon(icon, color: Colors.amber),
              Text(text, style: const TextStyle(color: Colors.amber))
            ]);
      },
      backgroundColor: Colors.red.withOpacity(0.3));

  /// 设置全局BottomSheet配置
  flExtended.bottomSheetOptions = const BottomSheetOptions(
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(top: Radius.circular(12))));
  flExtended.dialogOptions =
      const DialogOptions(fromStyle: PopupFromStyle.fromTop);

  /// 设置全局Wheel配置
  flExtended.wheelOptions = const WheelOptions.cupertino();

  flExtended.logCrossLine = true;

  /// 设置全局Loading配置
  flExtended.loadingOptions = LoadingOptions(
      backgroundColor: Colors.red.withOpacity(0.3),
      custom: const BText('全局设置loading', fontSize: 20),
      onModalTap: closeLoading);

  runApp(DevicePreview(
      enabled: isDesktop || isWeb,
      defaultDevice: Devices.ios.iPhone13Mini,
      builder: (context) => const _MaterialApp()));
}

class _MaterialAppRouter extends StatelessWidget {
  _MaterialAppRouter();

  final GoRouter _router =
      GoRouter(navigatorKey: FlExtended().navigatorKey, routes: <RouteBase>[]);

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(routerConfig: _router);
  }
}

class _MaterialApp extends StatelessWidget {
  const _MaterialApp();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        navigatorKey: FlExtended().navigatorKey,
        scaffoldMessengerKey: FlExtended().scaffoldMessengerKey,
        locale: DevicePreview.locale(context),
        theme: AppThemeData.light,
        darkTheme: AppThemeData.dark,
        title: 'Fl Extended',
        home: ExtendedScaffold(
            enableDoubleClickExit: true,
            appBar: AppBarText('Flutter extended example'),
            child: _Home()),
        builder: DevicePreview.appBuilder);
  }
}

class _Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Universal(
        padding: const EdgeInsets.all(10),
        isWrap: true,
        isScroll: true,
        wrapAlignment: WrapAlignment.center,
        direction: Axis.horizontal,
        scrollDirection: Axis.vertical,
        children: [
          ElevatedText('Text', onTap: () => push(const TextPage())),
          ElevatedText('Button', onTap: () => push(const ButtonPage())),
          ElevatedText('State Components',
              onTap: () => push(const StateComponentsPage())),
          ElevatedText('IconBox', onTap: () => push(const IconBoxPage())),
          ElevatedText('FlAnimation',
              onTap: () => push(const FlAnimationPage())),
          ElevatedText('Popup', onTap: () => push(const PopupPage())),
          ElevatedText('Overlay', onTap: () => push(const OverlayPage())),
          ElevatedText('Universal', onTap: () => push(const UniversalPage())),
          ElevatedText('ScrollView', onTap: () => push(const ScrollViewPage())),
          ElevatedText('ScrollList', onTap: () => push(const ScrollListPage())),
          ElevatedText('ListWheel', onTap: () => push(const ListWheelPage())),
          ElevatedText('EasyRefreshed',
              onTap: () => push(const EasyRefreshPage())),
          ElevatedText('DecoratorBox',
              onTap: () => push(const DecoratorBoxPage())),
          ElevatedText('ExtendedTextField',
              onTap: () => push(const TextFieldPage())),
          ElevatedText('ExtendedBuilder',
              onTap: () => push(const ExtendedBuilderPage())),
        ]);
  }
}

class AppBarText extends AppBar {
  AppBarText(String text, {super.key})
      : super(
            elevation: 0,
            title: BText(text, fontSize: 18, fontWeight: FontWeight.bold),
            centerTitle: true);
}

class ElevatedText extends StatelessWidget {
  const ElevatedText(this.text, {this.onTap, super.key});

  final VoidCallback? onTap;
  final String text;

  @override
  Widget build(BuildContext context) {
    return Universal(
        padding: const EdgeInsets.all(5),
        margin: const EdgeInsets.all(5),
        unifiedButtonCategory: UnifiedButtonCategory.elevated,
        onTap: onTap,
        child: BText(text));
  }
}

class Partition extends StatelessWidget {
  const Partition(this.title, {super.key, this.onTap});

  final String title;
  final GestureTapCallback? onTap;

  @override
  Widget build(BuildContext context) => Universal(
      onTap: onTap,
      width: double.infinity,
      color: Colors.grey.withOpacity(0.2),
      alignment: Alignment.center,
      padding: const EdgeInsets.all(10),
      margin: const EdgeInsets.symmetric(vertical: 20),
      child: BText(title,
          textAlign: TextAlign.center, fontWeight: FontWeight.bold));
}

const List<Color> colorList = <Color>[
  ...Colors.accents,
  ...Colors.primaries,
];

List<BoxShadow> getBoxShadow(
        {int num = 1,
        Color color = Colors.black12,
        double? radius,
        BlurStyle blurStyle = BlurStyle.normal,
        double blurRadius = 0.05,
        double spreadRadius = 0.05,
        Offset? offset}) =>
    num.generate((index) => BoxShadow(
        color: color,
        blurStyle: blurStyle,
        blurRadius: radius ?? blurRadius,
        spreadRadius: radius ?? spreadRadius,
        offset: offset ?? const Offset(0, 0)));
1
likes
0
pub points
65%
popularity

Publisher

unverified uploader

Some extension components and methods have been added to flutter and the routing functionality has been simplified

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, easy_refresh, flutter, flutter_staggered_grid_view

More

Packages that depend on fl_extended