Size: a a a

Dart & Flutter по-русски

2021 March 11

Б

Быков in Dart & Flutter по-русски
Спасибо большое!
источник

TP

The Professional in Dart & Flutter по-русски
Быков
Ничего не ругается
Попробуй еще раз сделать проект
источник

n_

nikto _b in Dart & Flutter по-русски
ребятки, как правильно кастовать Object? в свой класс?
источник

TP

The Professional in Dart & Flutter по-русски
Кто нибудь помогите мне с моим траблом выше
источник

П

П in Dart & Flutter по-русски
Ребята, как обновлять лист Вью каждую секунду?
источник

TP

The Professional in Dart & Flutter по-русски
Или тут сидят только те кто не умеют пользоваться командной строкой
источник

TP

The Professional in Dart & Flutter по-русски
🤣
источник

n_

nikto _b in Dart & Flutter по-русски
допустим
class MyClass{var field;}
и есть
Object? something
как превратить Object? в MyClass?
источник

n_

nikto _b in Dart & Flutter по-русски
The Professional
Или тут сидят только те кто не умеют пользоваться командной строкой
так а что у тебя?
источник

TP

The Professional in Dart & Flutter по-русски
The Professional
Launching lib/main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
E/flutter (16050): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method isRegisteredToBackend on channel net.plzft.poc_od)
E/flutter (16050): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157:7)
E/flutter (16050): <asynchronous suspension>
E/flutter (16050): #1      Logitmeplugin.isRegisteredToBackend (package:logitmeplugin/logitmeplugin.dart:16:26)
E/flutter (16050): <asynchronous suspension>
E/flutter (16050): #2      InitPageState.initIsRegisteredToBackend (package:logitmeplugin_example/init_page.dart:44:14)
E/flutter (16050): <asynchronous suspension>
E/flutter (16050):
E/flutter (16050): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
1
источник

n_

nikto _b in Dart & Flutter по-русски
П
Ребята, как обновлять лист Вью каждую секунду?
гуглани таймеры и просто вызывай обновление стейта каждую секунду
но, кажется, есть варианты лучше
источник

TP

The Professional in Dart & Flutter по-русски
The Professional
Я сделал канал, сделал метод но почему то флаттер не видит мой метод))


override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {

   if (call.method.equals("isRegisteredToBackend")) {

     result.success(LegicApi.getInstance().isRegisteredToBackend)
   }
###################################################
 static Future<bool> get isRegisteredToBackend async {
   final bool version = await _channel.invokeMethod('isRegisteredToBackend');
   print(version);
   return version;
 }
2
источник

ДЩ

Дмитрий Щербаков... in Dart & Flutter по-русски
The Professional
Launching lib/main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
E/flutter (16050): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method isRegisteredToBackend on channel net.plzft.poc_od)
E/flutter (16050): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157:7)
E/flutter (16050): <asynchronous suspension>
E/flutter (16050): #1      Logitmeplugin.isRegisteredToBackend (package:logitmeplugin/logitmeplugin.dart:16:26)
E/flutter (16050): <asynchronous suspension>
E/flutter (16050): #2      InitPageState.initIsRegisteredToBackend (package:logitmeplugin_example/init_page.dart:44:14)
E/flutter (16050): <asynchronous suspension>
E/flutter (16050):
E/flutter (16050): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
покажи свой java или kt активити
источник

Б

Быков in Dart & Flutter по-русски
The Professional
Попробуй еще раз сделать проект
Через терминал заработал, ещё раз спасибо!
источник

TP

The Professional in Dart & Flutter по-русски
Дмитрий Щербаков
покажи свой java или kt активити
package com.logitme.logitmeplugin

import android.app.Activity
import android.content.ContentValues.TAG
import android.content.Context
import android.os.Bundle
import android.os.Message
import android.util.Log
import androidx.annotation.NonNull

import com.logitme.plugins.logitmeplugin.LegicApi
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel


class MainActivity: FlutterPlugin, MethodChannel.MethodCallHandler{


 /// The MethodChannel that will the communication between Flutter and native Android
 ///
 /// This local reference serves to register the plugin with the Flutter Engine and unregister it
 /// when the Flutter Engine is detached from the Activity
 private lateinit var channel : MethodChannel
 private lateinit var context: Context
 private lateinit var activity: Activity


 override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
     var api = LegicApi.getInstance()
   //channel= MethodChannel(flutterPluginBinding.binaryMessenger,"net.plzft.poc_od")
   channel= MethodChannel(flutterPluginBinding.flutterEngine.dartExecutor,"net.plzft.poc_od")
   context = flutterPluginBinding.applicationContext
   channel.setMethodCallHandler(this)

 }


 override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {

   if (call.method.equals("isRegisteredToBackend")) {

     result.success(LegicApi.getInstance().isRegisteredToBackend)
   } else {
     result.notImplemented()
   }
 }

 override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
   channel.setMethodCallHandler(null)
 }


}
источник

n_

nikto _b in Dart & Flutter по-русски
первое - это никак не относится к cli
второе - скорее всего где-то надо регать весь список методов, не шарю
источник

TP

The Professional in Dart & Flutter по-русски
Дмитрий Щербаков
покажи свой java или kt активити
public class LegicApi implements LegicMobileSdkSynchronizeEventListener, LegicMobileSdkRegistrationEventListener,
       LegicNeonFileEventListenerV2, LegicReaderEventListenerV2, LegicMobileSdkPasswordEventListener,
       LegicMobileSdkEventListener {
   protected static LegicMobileSdkManager mManager;
   protected static LegicApi legicApi = null;
   protected static String channel = null;
   protected static FlutterView flutterView = null;
   protected static Activity activity = null;
   protected static Context context = null;
   protected static MethodChannel mc = null;

   private JSONArray logEntrys;
   private LegicNeonFile bleAccessedFile;

   LegicApi() throws LegicMobileSdkException {
       this.logEntrys = new JSONArray();
       initSdk();
       //mc = new MethodChannel(channel,flutterView);

   }

   public static LegicApi getInstance() throws LegicMobileSdkException {
       if (legicApi == null)
           legicApi = new LegicApi();

       return legicApi;
   }
источник

TP

The Professional in Dart & Flutter по-русски
Dart
############################

import 'dart:async';

import 'package:flutter/services.dart';

class Logitmeplugin {
 static const MethodChannel _channel =
     const MethodChannel('net.plzft.poc_od');

 static Future<String> get platformVersion async {
   final String version = await _channel.invokeMethod('getPlatformVersion');
   return version;
 }

 static Future<bool> get isRegisteredToBackend async {
   final bool version = await _channel.invokeMethod('isRegisteredToBackend');
   print(version);
   return version;
 }
}
###########################################################
import 'dart:developer';

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';
import 'package:logitmeplugin/logitmeplugin.dart';
import 'package:shared_preferences/shared_preferences.dart';

class InitPage extends StatefulWidget {
 @override
 InitPageState createState() => InitPageState();
}

class InitPageState extends State<InitPage> {
 @override
 void initState() {
   super.initState();

   setState(() {
     _isRegisteredToBackend = null;
   });

   initIsRegisteredToBackend();
   initVibrateState();
 }

 void initVibrateState() async {
   final prefs = await SharedPreferences.getInstance();
   prefs.setInt('notifications', 1);
 }

 //static const platform = const MethodChannel('net.plzft.poc_od');

 bool _isRegisteredToBackend = false;

 bool isRegisteredToBackend() {
   return _isRegisteredToBackend;
 }

 Future<void> initIsRegisteredToBackend() async {
   bool temp;
   // Platform messages may fail, so we use a try/catch PlatformException.
   try {
     temp = await Logitmeplugin.isRegisteredToBackend;
   } on PlatformException {
     temp = false;
   }

   // If the widget was removed from the tree while the asynchronous platform
   // message was in flight, we want to discard the reply rather than calling
   // setState to update our non-existent appearance.
   if (!mounted) return;

   if (!temp && _isRegisteredToBackend != temp) {
     log('_isRegisteredToBackend: $temp');
     setState(() {
       _isRegisteredToBackend = temp;
     });
     Navigator.popAndPushNamed(context, '/welcome_page');
   }

   if (temp) {
     Navigator.popAndPushNamed(context, '/home_page');
   }

 }

 @override
 Widget build(BuildContext context) {
   return Scaffold(
     body: Center(
       child: Column(
         crossAxisAlignment: CrossAxisAlignment.center,
         children: [
           new CircularProgressIndicator(),
         ],
       ),
     ),
   );
 }
}
источник

SH

Say Hello in Dart & Flutter по-русски
привет, как мне получить информацию с PostgreSQL и фотографий с моего сервера?

хочу реализовать правильно с flutter
источник

ДЩ

Дмитрий Щербаков... in Dart & Flutter по-русски
The Professional
public class LegicApi implements LegicMobileSdkSynchronizeEventListener, LegicMobileSdkRegistrationEventListener,
       LegicNeonFileEventListenerV2, LegicReaderEventListenerV2, LegicMobileSdkPasswordEventListener,
       LegicMobileSdkEventListener {
   protected static LegicMobileSdkManager mManager;
   protected static LegicApi legicApi = null;
   protected static String channel = null;
   protected static FlutterView flutterView = null;
   protected static Activity activity = null;
   protected static Context context = null;
   protected static MethodChannel mc = null;

   private JSONArray logEntrys;
   private LegicNeonFile bleAccessedFile;

   LegicApi() throws LegicMobileSdkException {
       this.logEntrys = new JSONArray();
       initSdk();
       //mc = new MethodChannel(channel,flutterView);

   }

   public static LegicApi getInstance() throws LegicMobileSdkException {
       if (legicApi == null)
           legicApi = new LegicApi();

       return legicApi;
   }
попробуй в mainactivity
источник