cherry_flutter 0.0.4 copy "cherry_flutter: ^0.0.4" to clipboard
cherry_flutter: ^0.0.4 copied to clipboard

outdated

flutter Personal tools, only for personal work and study, do not like to spray.

example/lib/main.dart

import 'package:cherry_flutter/cherry_flutter.dart';
import 'package:example/demo/dialog.dart';
import 'package:example/demo/popup_menu.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'demo/action_sheet.dart';
import 'demo/appbar.dart';
import 'demo/button.dart';
import 'demo/divider.dart';
import 'demo/popup_menu_box.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  TextEditingController controller = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.white,
        appBar: AppBar(title: Text('Cherry ui')),
        body: SingleChildScrollView(
          child: Container(
            width: double.infinity,
            padding: EdgeInsets.symmetric(vertical: 20, horizontal: 20),
            child: Wrap(
              runSpacing: 20,
              alignment: WrapAlignment.spaceBetween,
              children: [
                _Item(
                  title: 'button',
                  onTap: () {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                      return ButtonPage();
                    }));
                  },
                ),
                _Item(
                  title: 'Divider',
                  onTap: () {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                      return DividerDemo();
                    }));
                  },
                ),
                _Item(
                  title: 'ActionSheet',
                  onTap: () {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                      return ActionSheetDemo();
                    }));
                  },
                ),
                _Item(
                  title: 'Dialog',
                  onTap: () {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                      return DialogDemo();
                    }));
                  },
                ),
                _Item(
                  title: 'Popup menu',
                  onTap: () {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                      return PopupMenuDemo();
                    }));
                  },
                ),
                _Item(
                  title: 'Popup menu box',
                  onTap: () {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                      return PopupMenuBoxDemo();
                    }));
                  },
                ),
                _Item(
                  title: 'appbar',
                  onTap: () {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                      return AppBarDemo();
                    }));
                  },
                ),
                OutlineBorderField(
                  // onChanged: (_) => logic.checkResetPasswordForm(),
                  controller: controller,
                  title: '确认密码',
                  hintText: '确认登录密码',
                  type: 'password',
                  showEyes: true,
                  clearable: true,
                ),
              ],
            ),
          ),
        ));
  }
}

class OutlineBorderField extends StatelessWidget {
  final TextEditingController controller;
  final String? title;
  final String? hintText;
  final String type;
  final bool clearable;
  final bool showEyes;
  final bool required;
  final TextInputType? keyboardType;
  final List<TextInputFormatter>? inputFormatters;
  final ValueChanged<String>? onChanged;
  final bool readonly;

  const OutlineBorderField({
    Key? key,
    required this.controller,
    this.title,
    this.hintText,
    this.type = 'text',
    this.clearable = false,
    this.showEyes = false,
    this.required = false,
    this.keyboardType,
    this.inputFormatters,
    this.onChanged,
    this.readonly = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        if (title != null)
          Container(
            margin: EdgeInsets.only(bottom: 10),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                Text(
                  title!,
                  style: TextStyle(
                      fontSize: 12, color: const Color(0xff111111)),
                ),
                if (required)
                  Text('*',
                      style: TextStyle(
                          fontSize: 12, color: const Color(0xffB3272A)))
              ],
            ),
          ),
        CHField(
          onChanged: onChanged,
          controller: controller,
          height: 40,
          type: type,
          readonly: readonly,
          clearable: clearable,
          showEyes: showEyes,
          hintText: hintText,
          style: TextStyle(fontSize: 14, color: const Color(0xff111111)),
          hintStyle: TextStyle(
              fontSize: 14, color: const Color(0xffCCCCCC), height: 1),
          enabledBorder: OutlineInputBorder(
              borderRadius: BorderRadius.circular(1),
              borderSide:
              BorderSide(width: 1, color: const Color(0xffEEEEEE))),
          focusBorder: OutlineInputBorder(
              borderRadius: BorderRadius.circular(1),
              borderSide: BorderSide(
                  width: 1, color: Theme.of(context).primaryColor)),
        ),
      ],
    );
  }
}

class _Item extends StatelessWidget {
  final String title;
  final GestureTapCallback? onTap;

  const _Item({Key? key, required this.title, this.onTap}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        width: 100,
        height: 100,
        alignment: Alignment.center,
        decoration: BoxDecoration(color: Colors.white, boxShadow: [
          BoxShadow(
            color: Colors.black12,
            blurRadius: 10.0,
            spreadRadius: 0,
            offset: Offset(0, 2),
          )
        ]),
        child: Text(title),
      ),
    );
  }
}
0
likes
0
pub points
23%
popularity

Publisher

unverified uploader

flutter Personal tools, only for personal work and study, do not like to spray.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on cherry_flutter