Skip to content

Instantly share code, notes, and snippets.

@lwlizhe
lwlizhe / primary_page_view
Last active May 24, 2024 11:44
FLutter Nested Primary PageView
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/physics.dart';
import 'package:flutter/rendering.dart';
@lwlizhe
lwlizhe / gist:2a0ad72a9d9d253e7098fcc9dad111e8
Last active September 25, 2019 06:34
flutter 小说阅读器分页逻辑
/// em…………由于大量文字计算,即Cpu计算,在UI的Isolate会阻塞后续的UI事件(例如跳转,动画啥的),所以采取新建Isolate的方式,这也是flutter中建议的&……
/// 但是目前尴尬的是:
/// 非UI的Isolate不支持UI控件,即下面的textPainter.layout废了……一调用就报错
/// https://github.com/flutter/flutter/issues/30604
/// 所以,理论上来说,这块的计算应该放到一个子线程中,对于目前功能来说,也可以说是isolate中,但是flutter 现在不支持……
/// 现在个人有几种想法:
/// 1、翻页的时候动态计算,只缓存几页的内容,下次翻页的时候再计算
/// 2、https://github.com/flutter/flutter/issues/30604 裁剪canvas
/// 3、平台计算……