From 1bc8601a54264ae4df5755002e2470bf7adfc5f4 Mon Sep 17 00:00:00 2001 From: iampawan Date: Mon, 19 Apr 2021 17:33:02 +0530 Subject: [PATCH] Bug Fixes --- CHANGELOG.md | 2 ++ example/lib/widgets/platform_widget.dart | 9 ++++++++- lib/src/flutter/platforms.dart | 22 ++++++++++++++++------ lib/src/flutter/textfield.dart | 4 ++-- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01b30b5..e61898d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - New Preview Widget - VxPreview - New Drawers - VxDrawer - Added cursor and other props to VxTextField +- Bug Fixes for VxTextField +- Breaking - Desktop support added for VxPlatform - Minor Bug Fixes - Examples updated diff --git a/example/lib/widgets/platform_widget.dart b/example/lib/widgets/platform_widget.dart index 0f0580a..a108ee0 100644 --- a/example/lib/widgets/platform_widget.dart +++ b/example/lib/widgets/platform_widget.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:velocity_x/velocity_x.dart'; class PlatformBar - extends VxPlatform { + extends VxPlatform { @override AppBar createAndroidWidget(BuildContext context) { return AppBar( @@ -35,4 +35,11 @@ class PlatformBar ), ); } + + @override + AppBar createDesktopWidget(BuildContext context) { + return AppBar( + title: "Hello World".text.make(), + ); + } } diff --git a/lib/src/flutter/platforms.dart b/lib/src/flutter/platforms.dart index db9439b..8bbd85d 100644 --- a/lib/src/flutter/platforms.dart +++ b/lib/src/flutter/platforms.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; /// Sample /// -/// class PlatformAppBar extends VxPlatform { +/// class PlatformAppBar extends VxPlatform { /// final Widget title; /// final Widget leading; /// PlatformAppBar({ @@ -14,26 +14,31 @@ import 'package:flutter/material.dart'; /// /// @override /// CupertinoNavigationBar createIosWidget(BuildContext context) => -/// new CupertinoNavigationBar( +/// CupertinoNavigationBar( /// leading: leading, /// middle: title, /// ); /// /// @override -/// AppBar createAndroidWidget(BuildContext context) => new AppBar( +/// AppBar createAndroidWidget(BuildContext context) => AppBar( /// leading: leading, /// title: title, /// ); /// @override -/// AppBar createWebWidget(BuildContext context) => new AppBar( +/// AppBar createWebWidget(BuildContext context) => AppBar( +/// leading: leading, +/// title: title, +/// ); +/// @override +/// AppBar createDesktopWidget(BuildContext context) => AppBar( /// leading: leading, /// title: title, /// ); ///} /// -abstract class VxPlatform - extends StatelessWidget { +abstract class VxPlatform extends StatelessWidget { @override Widget build(BuildContext context) { if (kIsWeb) { @@ -42,6 +47,10 @@ abstract class VxPlatform return createAndroidWidget(context); } else if (defaultTargetPlatform == TargetPlatform.iOS) { return createIosWidget(context); + } else if (defaultTargetPlatform == TargetPlatform.macOS || + defaultTargetPlatform == TargetPlatform.linux || + defaultTargetPlatform == TargetPlatform.windows) { + return createDesktopWidget(context); } // platform not supported returns an empty widget return const Offstage(); @@ -50,4 +59,5 @@ abstract class VxPlatform A createAndroidWidget(BuildContext context); I createIosWidget(BuildContext context); W createWebWidget(BuildContext context); + D createDesktopWidget(BuildContext context); } diff --git a/lib/src/flutter/textfield.dart b/lib/src/flutter/textfield.dart index 2b0e4c4..7fc0c3a 100644 --- a/lib/src/flutter/textfield.dart +++ b/lib/src/flutter/textfield.dart @@ -295,7 +295,7 @@ class _VxTextFieldState extends State { /// After the completion of editing void onEditingComplete() { -// FocusScope.of(context).unfocus(); + FocusScope.of(context).unfocus(); if (widget.onEditingComplete != null) { widget.onEditingComplete!(); } @@ -303,7 +303,7 @@ class _VxTextFieldState extends State { /// After submitting the textfield void onSubmitted(String value) { -// FocusScope.of(context).unfocus(); + FocusScope.of(context).unfocus(); if (widget.onSubmitted != null) { widget.onSubmitted!(value); }