Coder Social home page Coder Social logo

xdd666t / flutter_use Goto Github PK

View Code? Open in Web Editor NEW
602.0 602.0 119.0 78.6 MB

some trick used by flutter | Flutter使用的一些*操作

Home Page: https://xdd666t.github.io/flutter_use/web/index.html

License: MIT License

Kotlin 0.03% Swift 0.51% Objective-C 0.01% Dart 87.38% CMake 4.76% C++ 6.02% C 0.35% HTML 0.30% Ruby 0.33% Shell 0.31%

flutter_use's Issues

No constructor 'GetMaterialApp.' with matching arguments declared in class 'GetMaterialApp'.

build windows应用时,修改代码后hot reload报错

Flutter版本

Flutter (Channel stable, 2.0.4, on Microsoft Windows [Version 10.0.18363.778], locale zh-CN)

详细错误

======== Exception caught by widgets library =======================================================
The following NoSuchMethodError was thrown building MyApp(dirty):
No constructor 'GetMaterialApp.' with matching arguments declared in class 'GetMaterialApp'.
Receiver: GetMaterialApp
Tried calling: new GetMaterialApp.()
Found: new GetMaterialApp.({Key? key, GlobalKey<NavigatorState>? navigatorKey, Widget? home, Map<String, (BuildContext) => Widget> routes, String? initialRoute, ((RouteSettings) => Route<dynamic>?)? onGenerateRoute, ((String) => List<Route<dynamic>>)? onGenerateInitialRoutes, ((RouteSettings) => Route<dynamic>?)? onUnknownRoute, List<NavigatorObserver> navigatorObservers, ((BuildContext, Widget?) => Widget)? builder, TextDirection? textDirection, String title, ((BuildContext) => String)? onGenerateTitle, Color? color, ThemeData? theme, ThemeData? darkTheme, ThemeMode themeMode, Locale? locale, Locale? fallbackLocale, Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates, ((List<Locale>?, Iterable<Locale>) => Locale?)? localeListResolutionCallback, ((Locale?, Iterable<Locale>) => Locale?)? localeResolutionCallback, Iterable<Locale> supportedLocales, bool debugShowMaterialGrid, bool showPerformanceOverlay, bool checkerboardRasterCacheImages, bool checkerboardOffscreenLayers, bool showSemanticsDebugger, bool debugShowCheckedModeBanner, Map<LogicalKeySet, Intent>? shortcuts, CustomTransition? customTransition, Map<String, Map<String, String>>? translationsKeys, Translations? translations, (() => void)? onInit, (() => void)? onReady, (() => void)? onDispose, ((Routing?) => void)? routingCallback, Transition? defaultTransition, List<GetPage<dynamic>>? getPages, bool? opaqueRoute, bool? enableLog, ((String, {bool isError}) => void)? logWriterCallback, bool? popGesture, Duration? transitionDuration, bool? defaultGlobalState, SmartManagement smartManagement, Bindings? initialBinding, GetPage<dynamic>? unknownRoute, ThemeData? highContrastTheme, ThemeData? highContrastDarkTheme, Map<Type, Action<Intent>>? actions}) => GetMaterialApp

Widget creation tracking is currently disabled. Enabling it enables improved error messages. It can be enabled by passing `--track-widget-creation` to `flutter run` or `flutter test`.
When the exception was thrown, this was the stack: 
#0      NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:212:5)
#1      MyApp.build (package:flutter_use/main.dart)
#2      StatelessElement.build (package:flutter/src/widgets/framework.dart:4569:28)
#3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4495:15)
#4      Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
...
====================================================================================================

DeferredRouter方法疑问

`class DeferredRouter extends StatelessWidget {
const DeferredRouter({
Key? key,
required this.future,
required this.builder,
}) : super(key: key);

final Future future;

final WidgetBuilder builder;

@OverRide
Widget build(BuildContext context) {
return FutureBuilder(
future: future,
builder: (context, snapshot) {
// web scene
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}
if (snapshot.connectionState != ConnectionState.done) {
return const Center(child: CircularProgressIndicator());
}
return builder(context);
},
);
}
} DeferredRouter(
future: deferred_lexicon_favorite.loadLibrary(),
builder: (_) => deferred_lexicon_favorite.LexiconFavoritePage(),
)`
大佬,看了您的demo里面这个路由懒加载,也查了资料,想请教下,我理解的页面本身就是用到的时候才会加载,这里又用了一个异步组件,这个是说对页面的载入懒加载吗,具体是加载的什么东西。
还有跟DeferredRouter同一个目录的DeferredWidget类也没看到哪里引用到了。

flutter 2.0.2编译失败

windows上失败日志:
/C:/flutter/.pub-cache/git/flutter_toolkit-8ae48d60794a4998f82cc685aadef2d5b5eba4a1/lib/src/net/src/interceptor/error_interceptor.dart(9,10): error G76A9B1F6: The method 'ErrorInterceptor.onError' has fewer positional arguments than those of overridden method 'Interceptor.onError'. [D:\Code\flutter_use\build\windows\flutter\flutter_assemble.vcxproj]
/C:/flutter/.pub-cache/git/flutter_toolkit-8ae48d60794a4998f82cc685aadef2d5b5eba4a1/lib/src/net/src/interceptor/error_interceptor.dart(15,25): error G4117F63E: Too few positional arguments: 2 required, 1 given. [D:\Code\flutter_use\build\windows\flutter\flutter_assemble.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(240,5): error MSB8066: “D:\Code\flutter_use\build\windows\CMakeFiles\28380f36d5341bfcdb8c161a898f2e6f\flutter_windows.dll.rule;D:\Code\flutter_use\build\windows\CMakeFiles\b8af8cce732b11c57a701b8e807268af\flutter_assemble.rule”的自定义生成已退 出,代码为 1。 [D:\Code\flutter_use\build\windows\flutter\flutter_assemble.vcxproj]
Building Windows application...
Build process failed.

windows打包问题

想问一下 windows打release包是如何打的 我打的包使用了sqflite_common_ffi 运行时无法创建数据库 不知道是打包问题还是需要怎么配置数据库

bloc单个变量改变问题。求助

在“flutter_bloc使用解析---*年,你还在手搭bloc吗!”文章的Bloc范例优化中提到
"注意:如果变量的数据未改变,界面相关的widget是不会重绘的;只会重绘变量被改变的widget"

在一个state class中有两个变量A、B,
有两个page:pageA、pageB分别根据A、B,进行blocbuilder,
定义两个event:eventA、eventB,
不论触发哪个事件改变A、B其中一个,pageA、pageB都会执行build
甚至两个变量值都没有改变,也会触发两个build,
但是,在官方使用extends Equatable,然后使用copywith方式中,A、B其中一个改变也会导致两个build都执行,但是A、B的值都没变时是不会执行build的
作者能解答一下我的疑问吗

class UserBloc extends Bloc<UserEvent, UserState> {
  UserBloc() : super(UserState().init()) {
    on<InitEvent>(_init);
    on<ChangeName>(_changeName);
    on<ChangeEmail>(_changeEmail);
  }

  void _init(InitEvent event, Emitter<UserState> emit) {
    emit(state.clone());
  }

  void _changeName(ChangeName event, Emitter<UserState> emit) {
    state.name = event.name;
    emit(state.clone());
  }

  void _changeEmail(ChangeEmail event, Emitter<UserState> emit) {
    state.email = event.email;
    emit(state.clone());
  }
}
abstract class UserEvent {}

class InitEvent extends UserEvent {}

class ChangeName extends UserEvent{
  final String name;
   ChangeName(this.name);
}

class ChangeEmail extends UserEvent{
  final String email;
  ChangeEmail(this.email);
}
class UserState {
  late String name;
  late String email;
  UserState init() {
    return UserState()
      ..name = 'zhan'
      ..email = '[email protected]';
  }

  UserState clone() {
    return UserState()
      ..name = name
      ..email = email;
  }
}
return Column(
      children: [
        BlocBuilder<UserBloc, UserState>(
          builder: (context, state) {
            debugPrint("name build");
            return Text(state.name);
          },
        ),
        Row(
          children: [
            ...省略
            TextButton(
              onPressed: () {
                BlocProvider.of<UserBloc>(context).add(ChangeName(nameC.text));
              },
              child: const Text("name"),
            ),
          ],
        ),
      ],
    );

AutoUi初始化问题

image

这里if (context != null) return; 岂不是永远不会执行下面的初始化代码

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.