Giter Club home page Giter Club logo

flutter-tutorial's Introduction

Flutter

Self study flutter SDK and dart language

Tools

Dynamic adding assets and images into pubspec.yaml file

https://github.com/ttpho/BuildAssets

Module

No Module Description
1 TimeUnit A TimeUnit represents time durations at a given unit of granularity and provides utility methods to convert across units, and to perform timing and delay operations in these units.
var d = TimeUnit.DAYS.toMillis(14);
2 YoutubeUriHelper The hepler class to detect youtube id and youtube media info

Project

No Project Screenshot
1 Pokemon Pocket
2 BoringAppBar
3 Split Screen video demo
4 Todo Application
5 SJC
6 MultiLanguages
7 Gradient review
8 shared_preferences_table
9 Display PDF from URL

flutter-tutorial's People

Contributors

ttpho avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

flutter-tutorial's Issues

[Flutter]In Container and Canvas documentation, explain why adjacent color blocks that aren't aligned on physical pixel boundaries show a seam

issues

Other

flutter/flutter#17084

How to fix

  • Use CustomPainter with custom painter
  • Replace Container by
    CustomPaint(
      size: Size(double.infinity, 49),
      painter: ContainnerColor(color: Colors.red),
    );

Painter class

import 'dart:ui';
import 'package:flutter/material.dart';

class ContainnerColor extends CustomPainter {
  ContainnerColor({
    this.color = Colors.red,
  }) {
    _drawPaint = Paint()
      ..color = this.color
      ..isAntiAlias = true
      ..style = PaintingStyle.fill;
  }

  final Color color;
  Paint _drawPaint;

  @override
  void paint(Canvas canvas, Size size) {
    canvas.drawRect(Offset(0, -1) & size, _drawPaint);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => false;
}

Flutter Web: Get Platform Name

/**
 * The source code origin:
 * by https://stackoverflow.com/users/4815056/vladyslav-turak
 * https://stackoverflow.com/a/38241481
 * @returns platform name, from ["macOS", "iOS", "windows", "android", "linux", null]
 */
function getPlatformName() {
  var userAgent = window.navigator.userAgent,
    platform = window.navigator.platform,
    macosPlatforms = ["Macintosh", "MacIntel", "MacPPC", "Mac68K"],
    windowsPlatforms = ["Win32", "Win64", "Windows", "WinCE"],
    iosPlatforms = ["iPhone", "iPad", "iPod"];

  if (macosPlatforms.indexOf(platform) !== -1) {
    return "macos";
  }
  if (iosPlatforms.indexOf(platform) !== -1) {
    return "ios";
  }
  if (windowsPlatforms.indexOf(platform) !== -1) {
    return "windows";
  }
  if (/Android/.test(userAgent)) {
    return "android";
  }
  if (!os && /Linux/.test(platform)) {
    return "linux";
  }

  return null;
}

Google Flutter Chart build with error: "The getter 'body1' isn't defined for the class 'TextTheme'".

Overview

Compiling lib/main.dart for the Web...                          
�[91mTarget dart2js failed: Exception: /root/.pub-cache/hosted/pub.dartlang.org/charts_flutter-0.9.0/lib/src/behaviors/legend/legend_entry_layout.dart:133:45:
Error: The getter 'body1' isn't defined for the class 'TextTheme'.
 - 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('../../flutter/packages/flutter/lib/src/material/text_theme.dart').
      color ??= Theme.of(context).textTheme.body1.color;
                                            ^^^^^
Error: Compilation failed.

Fixed

google/charts#676 (comment)

[flutter][web][mobile] Cross-origin images

Overview

  • Image.network does not display the image with Flutter Web
  • The HTML renderer can load cross-origin images without extra configuration.

Solution

Create ImageNetwork to load images from URL for web, Android, iOS , ...
image_network.dart

import 'package:flutter/material.dart';

import 'image_network_stub.dart'
if (dart.library.html) 'image_network_web.dart'
if (dart.library.io) 'image_network_io.dart';

class ImageNetwork extends StatelessWidget {
  final String src;

  const ImageNetwork({Key key, this.src}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return imageWithUrl(src);
  }
}

image_network_io.dart

import 'package:flutter/widgets.dart';

StatefulWidget imageWithUrl(String src) => Image.network(src);

image_network_web.dart

// ignore: avoid_web_libraries_in_flutter
import 'dart:html';
import 'dart:io' if (dart.library.html) 'dart:ui' as ui;
import 'package:flutter/widgets.dart';

StatefulWidget imageWithUrl(String src) => HtmlElementImage(src: src,);


class HtmlElementImage extends StatefulWidget {
  final String src;

  const HtmlElementImage({Key key, this.src}) : super(key: key);

  @override
  _HtmlElementImageState createState() => _HtmlElementImageState();
}

class _HtmlElementImageState extends State<HtmlElementImage> {
  Widget build(BuildContext context) {
    // ignore: undefined_prefixed_name
    ui.platformViewRegistry.registerViewFactory(
      widget.src,
          (int viewId) => ImageElement()..src = widget.src,
    );
    return HtmlElementView(
      viewType: widget.src,
    );
  }
}

image_network_stub.dart

import 'package:flutter/widgets.dart';

StatefulWidget imageWithUrl(String src) => throw UnsupportedError('No implementation for imageWithUrl');

Used

import 'image_network.dart';

Container(
                  width: 100,
                  height: 100,
                  child: ImageNetwork(
                      src: 'https://img.pokemondb.net/artwork/bulbasaur.jpg'),
                ),

Test

Android

Web
screencapture-localhost-59959-2021-04-01-09_56_35

Issues

[web] [CanvasKit] Image.network does not display the image #49725

[dart] Dart xml parser doesn’t decode UTF-8 characters

Dart [String] using the default UTF-16 encoding. The xml library has no way of knowing that your data is encoded differently.
Use utf8 of dart:convert to represent every character in the Unicode character set.

Before

    final response = await http.get(_baseUrl);
    return _parseXML(response.body);

After

    final response = await http.get(_baseUrl);
    return _parseXML(utf8.decode(response.bodyBytes));

Firebase for iOS

Error

Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 52347
This was attempt #200. Will retry in 0:00:01.600000.

Fixed :

https://stackoverflow.com/a/63869774

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.