overlay_container
1.0.0
아동을 원래 위젯 계층 외부에서 렌더링하는 플러터 위젯.

이 데모는 여기에 예로 들어 있습니다. examples 폴더를 확인할 수도 있습니다.
이 위젯으로 전달 된 아이는 기존 위젯 트리의 오버레이로 위젯 계층 외부에서 렌더링됩니다. 결과적 으로이 위젯은 사용자 정의 드롭 다운 옵션, 자동 완성 제안, 대화 상자 등을 구축하는 데 매우 적합합니다. 위젯을 절대적으로 배치하고 위젯 트리의 나머지 부분에 긍정적 인 z-index를 갖는 것으로 생각합니다. 실제로 플러터의 오버레이와 오버레이 아파이에 대한 친숙한 래퍼입니다.
반응을 사용한 적이 있다면, 이것은 반응 포털이 어떤 방식 으로든 수행하려고 시도합니다.
import 'package:flutter/material.dart' ;
import 'package:overlay_container/overlay_container.dart' ;
class MyApp extends StatelessWidget {
@override
Widget build ( BuildContext context) {
return MaterialApp (
title : 'Overlay Container Demo' ,
theme : ThemeData (
primarySwatch : Colors .blue,
),
home : MyHomePage (),
);
}
}
class MyHomePage extends StatefulWidget {
_MyHomePageState createState () => _MyHomePageState ();
}
class _MyHomePageState extends State < MyHomePage > {
// Need to maintain a "show" state either locally or inside
// a bloc.
bool _dropdownShown = false ;
void _toggleDropdown () {
setState (() {
_dropdownShown = ! _dropdownShown;
});
}
@override
Widget build ( BuildContext context) {
return Scaffold (
appBar : AppBar (
title : Text ( 'Overlay Container Demo Page' ),
),
body : Padding (
padding : const EdgeInsets . all ( 20 ),
child : Column (
crossAxisAlignment : CrossAxisAlignment .start,
children : < Widget > [
RaisedButton (
onPressed : _toggleDropdown,
child : Column (
children : < Widget > [
Text ( "Dropdown button" ),
],
),
),
// By default the overlay (since this is a Column) will
// be added right below the raised button
// but outside the widget tree.
// We can change that by supplying a "position".
OverlayContainer (
show : _dropdownShown,
// Let's position this overlay to the right of the button.
position : OverlayContainerPosition (
// Left position.
150 ,
// Bottom position.
45 ,
),
// The content inside the overlay.
child : Container (
height : 70 ,
padding : const EdgeInsets . all ( 20 ),
margin : const EdgeInsets . only (top : 5 ),
decoration : BoxDecoration (
color : Colors .white,
boxShadow : < BoxShadow > [
BoxShadow (
color : Colors .grey[ 300 ],
blurRadius : 3 ,
spreadRadius : 6 ,
)
],
),
child : Text ( "I render outside the n widget hierarchy." ),
),
),
],
),
),
);
}
}보다 정교한 예가 여기에 있습니다.