flutter Slide拖动滑条


main.dart 

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'This is a Slide Example',
        home: Scaffold(
            appBar: AppBar(
              title: Text('ABC'),
            ),
            body: Column(children: [
              Padding(
                child: Text(
                  'This is a Slide Example',
                  style: TextStyle(fontSize: 20),
                ),
                padding: EdgeInsets.all(50),
              ),
              SlideExample(),
              RangeSliderExample()
            ])));
  }
}

class SlideExample extends StatefulWidget {
  @override
  _Slider1State createState() => _Slider1State();
}

class _Slider1State extends State {
  double rating = 0;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build

    return Slider(
      label: "$rating",
      divisions: 10,
      value: rating,
      onChanged: (newRating) {
        setState(() => rating = newRating);
      },
    );
  }
}

class RangeSliderExample extends StatefulWidget {
  @override
  _RangeSliderExampleState createState() => _RangeSliderExampleState();
}

class _RangeSliderExampleState extends State {
  var selectedRange = RangeValues(0.2, 0.8);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return RangeSlider(
      values: selectedRange,
      onChanged: (RangeValues newRange) {
        setState(() {
          selectedRange = newRange;
        });
      },
    );
  }
}


空闲时间用Flutter写的安卓APP 金庸武侠小说集离线版

空闲时间用Flutter写的安卓APP 金庸武侠小说集离线版 ,Google Play上架中,APK版本直接下载:

https://zcdn.askmac.cn/%E9%87%91%E5%BA%B8%E6%AD%A6%E4%BE%A0%E5%B0%8F%E8%AF%B4%E9%9B%86%E7%A6%BB%E7%BA%BF%E7%89%88.apk

 

 

Flutter Widget创建时运行异步操作

样例代码

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build

    return MaterialApp(
        home: Scaffold(
      body: Center(child: AsyncTest()),
    ));
  }
}

class AsyncTest extends StatefulWidget {
  @override
  _AsyncTestState createState() => _AsyncTestState();
}

int getNumber(int n) {
  if (n == 0) {
    return 0;
  } else if (n == 1) {
    return 1;
  } else {
    return getNumber(n - 1) + getNumber(n - 2);
  }
}

Future loadAsset(BuildContext context) async {
  return await DefaultAssetBundle.of(context)
      .loadString('assets/novels/0-1.txt');
}

class _AsyncTestState extends State {
  bool loading = true;

  @override
  void initState() {
    super.initState();

    loadAsset(context).then((result) {
      debugPrint(
          'consume cpu time function result is ' + getNumber(20).toString());

      Future.delayed(Duration(seconds: 1)).then((result) {
        setState(() {
          loading = false;
        });
      });
    });
  }


  
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    if (loading == true) {
      return CircularProgressIndicator();
    }

    return Text('load finished ');
  }
}


几点说明:

  1. 使用StatefulWidget 有状态Widget
  2. 在initState函数中执行异步操作
  3. 保证在已有结果的状态下调用setState

 

 

参考:

https://flutter.institute/run-async-operation-on-widget-creation/

 

git npm brew yarn 配置proxy



all

export https_proxy=http://127.0.0.1:6152
export http_proxy=http://127.0.0.1:6152
export all_proxy=socks5://127.0.0.1:6153




git npm brew yarn 配置代理

//git列出
git config --global http.proxy

//git设置
git config --global http.proxy 'socks5://127.0.0.1:6153'

//git取消设置

git config --global --unset http.proxy



npm

//列出所有配置
npm config ls -l

//列出
npm config list

//设置

npm config set https-proxy http://127.0.0.1:6152
npm config set proxy http://127.0.0.1:6152



//npm 取消配置
npm config list delete https-proxy
npm config set proxy


//yarn 列出

yarn config list

//yarn 设置 

yarn config set proxy http://127.0.0.1:6152
yarn config set https-proxy http://127.0.0.1:6152


//yarn 取消配置

yarn config delete proxy
yarn config delete https-proxy



//brew 列出

all_proxy=socks5://127.0.0.1:6153 brew install mysql





flutter pub get缓慢解决方案

flutter pub get缓慢解决方案

windows

set PUB_HOSTED_URL=https://pub.flutter-io.cn
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

flutter pub get 

Linux MACOS

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

flutter pub get

react native css style field

 

ref:

https://github.com/macleanliu/learnjs/blob/master/css.ts

 

 

 

 

 

谷歌,微软,Mozilla组队启动WebAssembly,一种新的网页二进制格式

在着手WebKit项目的谷歌,微软,Mozilla和他们的工程师们,今天宣布他们已经联手推出WebAssembly,为Web编译应用程序的新的二进制格式。

 

网络蓬勃发展是基于一个标准,不论好坏,JavaScript是它的编程语言。然而多年来,我们看到越来越多的人努力在帮助开发人员解决一些JavaScript的限制,通过建立把其他语言转译成JavaScript的编译器。其中的一些项目关注增加语言的新功能(如微软的TypeScript),或加速JavaScript(如Mozilla的asm.js项目)。现在,许多项目已经开始通过WebAssmbly的形式走到一起。

新格式的目的是让程序员编写浏览器的代码(目前的主要是C / C ++,还有其他一些语言),它是在JavaScript引擎内部执行。它不必解析完整的代码,这往往需要相当长的时间(特别是在手机),WebAssembly可以显得加快解码。

[Read more…]

沪ICP备14014813号-2

沪公网安备 31010802001379号